Skip to content

Commit 399f185

Browse files
authored
Rebuild with new commit --allow-empty on rector-src when rector-src is tagged on trigger Rebuild (#388)
1 parent 089be4a commit 399f185

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# github action that rebuilds https://github.com/rectorphp/rector
2+
# with the freshly merged rector-downgrade-php main
3+
name: Dispatch Build Scoped Rector
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
workflow_dispatch: null
10+
11+
jobs:
12+
dispatch_build_scoped_rector:
13+
# only for this repository, not forks
14+
if: github.repository == 'rectorphp/rector-downgrade-php'
15+
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 10
18+
19+
steps:
20+
-
21+
name: "Wait 20 seconds after push"
22+
run: sleep 20
23+
24+
-
25+
name: "Check whether rector-src main is a release tag commit"
26+
env:
27+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
28+
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
29+
run: |
30+
RECTOR_SRC="https://github.com/rectorphp/rector-src.git"
31+
32+
MAIN_SHA=$(git ls-remote $RECTOR_SRC refs/heads/main | cut -f1)
33+
if [ -z "$MAIN_SHA" ]; then
34+
echo "Could not resolve rector-src main"
35+
exit 1
36+
fi
37+
38+
# lightweight tags are listed with the commit itself, annotated ones with a "^{}" line
39+
if git ls-remote --tags $RECTOR_SRC | grep -q "^${MAIN_SHA}"; then
40+
echo "rector-src main $MAIN_SHA is tagged, creating a rebuild commit"
41+
git clone --depth 1 --branch main "https://x-access-token:${ACCESS_TOKEN}@github.com/rectorphp/rector-src.git" rector-src
42+
cd rector-src
43+
git config user.name "TomasVotruba"
44+
git config user.email "tomas.vot@gmail.com"
45+
git commit --allow-empty -m 'Rebuild' -a
46+
git push origin main
47+
else
48+
gh workflow run build_scoped_rector.yaml --repo rectorphp/rector-src --ref main
49+
fi

0 commit comments

Comments
 (0)