-
Notifications
You must be signed in to change notification settings - Fork 8
126 lines (108 loc) · 4.44 KB
/
auto_cherry_pick.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Auto cherry-pick Keiyoushi
on:
schedule:
- cron: "0 */8 * * *"
workflow_dispatch: # Manual dispatch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
auto-merge:
name: Auto cherry-pick Keiyoushi
if: github.repository == 'komikku-app/komikku-extensions'
runs-on: ubuntu-latest
steps:
- name: Clone master
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
ref: master
path: master
fetch-depth: 100
token: ${{ secrets.BOT_PAT }}
- name: Import GPG key
id: import-gpg
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6
with:
workdir: master
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import-gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import-gpg.outputs.keyid }}"
echo "name: ${{ steps.import-gpg.outputs.name }}"
echo "email: ${{ steps.import-gpg.outputs.email }}"
- name: Cherry-picking
run: |
cd master
git fetch origin keiyoushi
git checkout keiyoushi
echo "Last commit: `git log -1 --oneline`"
git remote add keiyoushi-remote https://github.com/keiyoushi/extensions-source
git fetch keiyoushi-remote
echo "Last commit: `git log -1 --oneline keiyoushi-remote/main`"
echo "Incoming commits:"
echo "`git log keiyoushi..keiyoushi-remote/main --oneline`"
upcoming_changes=`git log keiyoushi..keiyoushi-remote/main --pretty="%h"`
# Read the upcoming changes' hash into an array
upcoming_changes_hash=()
while read -r line; do
upcoming_changes_hash+=("$line")
done <<< "$upcoming_changes"
git checkout master
echo "Last commit: `git log -1 --oneline`"
# Loop through indices in reverse order
for (( i=${#upcoming_changes_hash[@]}; i>=0; i-- )); do
if [ ! -z "${upcoming_changes_hash[i]}" -a "${upcoming_changes_hash[i]}" != " " ]; then
echo "[$i]: Cherry picking '${upcoming_changes_hash[i]}'"
git cherry-pick "${upcoming_changes_hash[i]}"
latest_hash=${upcoming_changes_hash[i]}
else
echo "[$i]: skip '${upcoming_changes_hash[i]}'"
fi
done
echo "Last commit: `git log -1 --oneline`"
echo "LATEST_HASH=${latest_hash}" >> $GITHUB_ENV
- name: Merging keiyoushi-remote to keiyoushi
run: |
cd master
git checkout keiyoushi
echo "Last commit: `git log -1 --oneline`"
latest_commit_hash=${{ env.LATEST_HASH }}
if [ ! -z "$latest_commit_hash" -a "$latest_commit_hash" != " " ]; then
echo "Merging commit '$latest_commit_hash' from 'keiyoushi-remote' into keiyoushi"
git merge "$latest_commit_hash" --no-ff -m "Merge branch 'keiyoushi-remote' into keiyoushi"
fi
echo "Last commit: `git log -1 --oneline`"
- name: Merging master to merge-keiyoushi
run: |
cd master
git fetch origin merge-keiyoushi
git checkout merge-keiyoushi
echo "Last commit: `git log -1 --oneline`"
echo "Merging 'master' into merge-keiyoushi"
git merge --no-edit master
echo "Last commit: `git log -1 --oneline`"
- name: Merging keiyoushi-remote to merge-keiyoushi
run: |
cd master
echo "Merging 'keiyoushi-remote/main' into merge-keiyoushi"
git merge -S --no-edit keiyoushi-remote/main
echo "Last commit: `git log -1 --oneline`"
- name: Pushing to repo
run: |
cd master
git checkout master
echo "Last commit: `git log -1 --oneline`"
echo "Pushing 'master' to repo"
git push
git checkout keiyoushi
echo "Last commit: `git log -1 --oneline`"
echo "Pushing 'keiyoushi' to repo"
git push
git checkout merge-keiyoushi
echo "Last commit: `git log -1 --oneline`"
echo "Pushing 'merge-keiyoushi' to repo"
git push