Skip to content

Commit d939a83

Browse files
committed
fix(docker): prevent skipped builds when queued runs are dropped
- Set cancel-in-progress: false so queued builds wait for the active run instead of cancelling it - Compare changed files against the last successful push-triggered build commit (via GitHub API), not just the parent commit - If no previous successful build exists, always build Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
1 parent c875018 commit d939a83

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/docker-build-and-push-new.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,39 @@ on:
1010

1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
13-
cancel-in-progress: true
13+
cancel-in-progress: false
1414

1515
jobs:
1616
changed-files:
1717
runs-on: ubuntu-24.04
1818
outputs:
19-
should-build: ${{ steps.check.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref_type == 'tag') }}
19+
should-build: ${{ steps.check.outputs.any_changed == 'true' || steps.last-success.outputs.sha == '' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref_type == 'tag') }}
2020
steps:
2121
- uses: actions/checkout@v6
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Find last successful build commit
26+
id: last-success
27+
env:
28+
GH_TOKEN: ${{ github.token }}
29+
run: |
30+
sha=$(gh api \
31+
"repos/${{ github.repository }}/actions/workflows/docker-build-and-push-new.yaml/runs?branch=main&status=success&event=push&per_page=1" \
32+
--jq '.workflow_runs[0].head_sha // empty')
33+
34+
if [ -n "$sha" ] && git cat-file -e "$sha" 2>/dev/null; then
35+
echo "sha=$sha" >> "$GITHUB_OUTPUT"
36+
echo "Found last successful build at $sha"
37+
else
38+
echo "sha=" >> "$GITHUB_OUTPUT"
39+
echo "No previous successful build found, will force build"
40+
fi
41+
2242
- id: check
2343
uses: step-security/changed-files@v47
2444
with:
45+
base_sha: ${{ steps.last-success.outputs.sha }}
2546
files: |
2647
docker-new/**
2748
ansible/**

0 commit comments

Comments
 (0)