Repository navigation
Expand file tree
/
Copy pathdispatch_build_scoped_rector.yaml
More file actions
51 lines (44 loc) · 2.24 KB
/
Copy pathdispatch_build_scoped_rector.yaml
File metadata and controls
51 lines (44 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# github action that rebuilds https://github.com/rectorphp/rector
# with the freshly merged rector-phpunit main
name: Dispatch Build Scoped Rector
# pull_request_target fires on merge even for fork PRs and, unlike "push",
# is not suppressed when the merge commit is pushed with GITHUB_TOKEN
on:
pull_request_target:
types:
- closed
workflow_dispatch: null
jobs:
dispatch_build_scoped_rector:
# only for this repository, not forks; and only on a merged PR (not a plain close)
if: github.repository == 'rectorphp/rector-phpunit' && (github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
-
name: "Wait 10 seconds after merge"
run: sleep 10
-
name: "Check whether rector-src main is a release tag commit"
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
RECTOR_SRC="https://github.com/rectorphp/rector-src.git"
MAIN_SHA=$(git ls-remote $RECTOR_SRC refs/heads/main | cut -f1)
if [ -z "$MAIN_SHA" ]; then
echo "Could not resolve rector-src main"
exit 1
fi
# lightweight tags are listed with the commit itself, annotated ones with a "^{}" line
if git ls-remote --tags $RECTOR_SRC | grep -q "^${MAIN_SHA}"; then
echo "rector-src main $MAIN_SHA is tagged, creating a rebuild commit"
git clone --depth 1 --branch main "https://x-access-token:${ACCESS_TOKEN}@github.com/rectorphp/rector-src.git" rector-src
cd rector-src
git config user.name "TomasVotruba"
git config user.email "tomas.vot@gmail.com"
git commit --allow-empty -m 'Rebuild' -a
git push origin main
else
gh workflow run build_scoped_rector.yaml --repo rectorphp/rector-src --ref main
fi