Skip to content

Commit

Permalink
Merge pull request #2333 from element-hq/fkwp/refactor_gh_action_run-id
Browse files Browse the repository at this point in the history
refactor run-id handling of GitHub Actions
  • Loading branch information
fkwp authored May 6, 2024
2 parents 56312b2 + af99d2a commit 2a0375d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
docker_tags:
required: true
type: string
artifact_run_id:
required: false
type: string
default: ${{ github.run_id }}

env:
REGISTRY: ghcr.io
Expand All @@ -25,7 +29,7 @@ jobs:
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id || github.run_id }}
run-id: ${{ inputs.artifact_run_id }}
name: build-output
path: dist

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/netlify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
deployment_ref:
required: true
type: string
artifact_run_id:
required: false
type: string
default: ${{ github.run_id }}
secrets:
ELEMENT_BOT_TOKEN:
required: true
Expand Down Expand Up @@ -45,7 +49,7 @@ jobs:
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.ELEMENT_BOT_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
run-id: ${{ inputs.artifact_run_id }}
name: build-output
path: webapp

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
deployments: write
uses: ./.github/workflows/netlify.yaml
with:
artifact_run_id: ${{ github.event.workflow_run.id || github.run_id }}
pr_number: ${{ needs.prdetails.outputs.pr_number }}
pr_head_full_name: ${{ github.event.workflow_run.head_repository.full_name }}
pr_head_ref: ${{ needs.prdetails.outputs.pr_data_json && fromJSON(needs.prdetails.outputs.pr_data_json).head.ref }}
Expand All @@ -43,6 +44,7 @@ jobs:
packages: write
uses: ./.github/workflows/docker.yaml
with:
artifact_run_id: ${{ github.event.workflow_run.id || github.run_id }}
docker_tags: |
type=sha,format=short,event=branch
type=raw,value=pr_${{ needs.prdetails.outputs.pr_number }}
1 change: 1 addition & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
packages: write
uses: ./.github/workflows/docker.yaml
with:
artifact_run_id: ${{ github.event.workflow_run.id || github.run_id }}
docker_tags: |
type=sha,format=short,event=branch
type=semver,pattern=v{{version}}
Expand Down

0 comments on commit 2a0375d

Please sign in to comment.