forked from shivammathur/php-src-backports
-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (71 loc) · 2.53 KB
/
sync.yml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Sync workflow
on:
workflow_dispatch:
inputs:
upstream:
type: choice
description: Upstream php-src repository
options:
- remicollet/php-src-security
- oerdnj/php-src-security
- microsoft/php-src
default: remicollet/php-src-security
required: true
run_build:
type: choice
description: Trigger workflow_dispatch for shivammathur/php tap
options:
- 'true'
- 'false'
default: 'true'
required: true
jobs:
sync:
name: sync
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update tags and branches
run: |
push_ref() {
ref=$1
git push -f https://${{ github.repository_owner }}:${{ secrets.TOKEN }}@github.com/${{ github.repository }}.git "$ref" || true
}
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote add up https://github.com/${{ github.event.inputs.upstream }}
git remote add php https://github.com/php/php-src
mapfile -t branches < <(git branch -r | sed 's/ *origin\///g')
mapfile -t tags < <(git tag --sort=-refname | awk 'match($0, /^[0-9]+\.[0-9]+\.[0-9]+/)')
cp -r patches /tmp
for branch in "${branches[@]}"; do
echo "---- $branch ----"
if [ "$branch" = "main" ]; then
continue
fi
git checkout "$branch"
git fetch up "$branch"
git reset --hard up/"$branch"
tag="$(echo $branch | cut -d '-' -f 2)"
if [ -e /tmp/patches/"$tag" ]; then
while read patch; do
git am < /tmp/patches/"$patch"
done < /tmp/patches/"$tag"
fi
push_ref "$branch"
done
for tag in "${tags[@]}"; do
echo "---- $tag ----"
git checkout "$tag"
suffix=""
[ "${tag%.*}" = "5.6" ] && suffix="openssl11"
git reset --hard "$(echo "${branches[@]}" | grep -Po "PHP-${tag%.*}-[a-zA-Z-]+$suffix" | head -n 1)"
git tag -fa "$tag" -m "Update $tag tag"
push_ref "$tag"
done
if [ '${{ github.event.inputs.run_build }}' = 'true' ]; then
GITHUB_TOKEN=${{ secrets.TOKEN }} gh workflow run build.yml -R shivammathur/homebrew-php
fi