-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Get Workflow Run ID | ||
|
||
Get the ID of the latest successful workflow run. | ||
|
||
Accepts the following inputs: | ||
|
||
* `repository` (Required) - The repository owner and name (e.g. `spring-projects/spring-security`). | ||
* `workflow-id` (Required) - The ID of the workflow or the workflow file name. | ||
|
||
Produces the following output: | ||
|
||
* `run-id` - The ID of the latest successful workflow run. | ||
|
||
## Installation | ||
|
||
```yaml | ||
- id: get-workflow-run-id | ||
name: Get Workflow Run ID | ||
uses: spring-io/spring-security-release-tools/.github/actions/get-workflow-run-id@v1 | ||
with: | ||
repository: owner/repo | ||
workflow-id: build-and-deploy.yml | ||
``` | ||
## Example Usage | ||
```yaml | ||
name: Download Artifacts | ||
|
||
on: push | ||
|
||
permissions: | ||
actions: read | ||
|
||
jobs: | ||
download-artifacts: | ||
name: Download Artifacts | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: get-workflow-run-id | ||
name: Get Workflow Run ID | ||
uses: spring-io/spring-security-release-tools/.github/actions/get-workflow-run-id@v1 | ||
with: | ||
repository: spring-projects/spring-security | ||
workflow-id: continuous-integration-workflow.yml | ||
- name: Download Artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: maven-repository | ||
path: build | ||
repository: spring-projects/spring-security | ||
github-token: ${{ github.token }} | ||
run-id: ${{ steps.get-workflow-run-id.outputs.run-id }} | ||
- name: Unzip Artifacts | ||
run: pushd build && unzip maven-repository.zip && popd | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: 'Get Workflow Run ID' | ||
description: 'Get the ID of the latest successful workflow run for a given workflow.' | ||
author: 'sjohnr' | ||
|
||
inputs: | ||
repository: | ||
description: 'The repository owner and name (e.g. spring-projects/spring-security).' | ||
required: true | ||
workflow-id: | ||
description: 'The ID of the workflow or the workflow file name (e.g. build-and-deploy.yml).' | ||
required: true | ||
|
||
outputs: | ||
run-id: | ||
description: 'The ID of the latest successful workflow run.' | ||
value: ${{ steps.get-workflow-run-id.outputs.run-id }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- id: get-workflow-run-id | ||
name: Get Workflow Run ID | ||
shell: bash | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
runId=$(gh run list -R ${{ inputs.repository }} -w ${{ inputs.workflow-id }} -s success --json databaseId -q '.[0].databaseId') | ||
echo "run-id=$runId" >> $GITHUB_OUTPUT |