Skip to content

Commit 772e06b

Browse files
committed
Skip the rebuild when rector-src main is a release tag commit
A tagged main is already published by the tag build of rector-src. A dispatched build would race that build for the push to rectorphp/rector, and the loser of the race fails on a non fast forward push. Tags are resolved with git ls-remote, which lists a lightweight tag with the commit itself and an annotated tag with an extra "^{}" line, so both kinds are matched. rector-src has 36 annotated tags among 574.
1 parent 059615d commit 772e06b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/dispatch_build_scoped_rector.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,29 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18+
# a tagged main is already being published by the tag build of rector-src,
19+
# dispatching a second build would race it for the push to rectorphp/rector
20+
-
21+
name: "Check whether rector-src main is a release tag commit"
22+
id: release_tag
23+
run: |
24+
RECTOR_SRC="https://github.com/rectorphp/rector-src.git"
25+
26+
MAIN_SHA=$(git ls-remote $RECTOR_SRC refs/heads/main | cut -f1)
27+
if [ -z "$MAIN_SHA" ]; then
28+
echo "Could not resolve rector-src main"
29+
exit 1
30+
fi
31+
32+
# lightweight tags are listed with the commit itself, annotated ones with a "^{}" line
33+
if git ls-remote --tags $RECTOR_SRC | grep -q "^${MAIN_SHA}"; then
34+
echo "rector-src main $MAIN_SHA is tagged, leaving the build to the tag itself"
35+
echo "tagged=true" >> $GITHUB_OUTPUT
36+
fi
37+
1838
-
1939
name: "Trigger build_scoped_rector.yaml in rectorphp/rector-src"
40+
if: steps.release_tag.outputs.tagged != 'true'
2041
env:
2142
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
2243
run: gh workflow run build_scoped_rector.yaml --repo rectorphp/rector-src --ref main

0 commit comments

Comments
 (0)