Repository navigation
106 lines (90 loc) · 3.7 KB
/
Copy pathAuto_Trigger.yml
File metadata and controls
106 lines (90 loc) · 3.7 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
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
name: Auto Trigger on SukiSU Update
on:
schedule:
- cron: '0 0 */3 * *' # 每两天执行一次
workflow_dispatch: # 允许手动触发
jobs:
check-and-trigger:
runs-on: ubuntu-latest
# 如果要运行自动编译工作流,请手动添加/修改仓库所有者用户名
if: contains(fromJSON('["zzh20188", "elysias123"]'), github.repository_owner)
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Get latest commit SHA from SukiSU-Ultra
id: get_sha
run: |
LATEST_SHA=$(curl -s https://api.github.com/repos/SukiSU-Ultra/SukiSU-Ultra/commits/main | jq -r '.sha')
echo "sha=$LATEST_SHA" >> $GITHUB_OUTPUT
echo "Latest SHA: $LATEST_SHA"
- name: Get previous SHA from sha branch
id: get_prev_sha
run: |
if git ls-remote --heads origin sha | grep -q sha; then
echo "SHA branch exists, fetching previous SHA..."
git fetch origin sha:sha || true
git checkout sha || true
if [ -f "latest_sha.txt" ]; then
PREV_SHA=$(cat latest_sha.txt)
echo "prev_sha=$PREV_SHA" >> $GITHUB_OUTPUT
echo "Previous SHA found: $PREV_SHA"
else
echo "prev_sha=" >> $GITHUB_OUTPUT
echo "No previous SHA file found"
fi
else
echo "prev_sha=" >> $GITHUB_OUTPUT
echo "SHA branch does not exist yet"
fi
git checkout ${{ github.ref_name }}
- name: Compare with previous SHA
id: compare
run: |
CURR_SHA="${{ steps.get_sha.outputs.sha }}"
PREV_SHA="${{ steps.get_prev_sha.outputs.prev_sha }}"
echo "Current SHA: $CURR_SHA"
echo "Previous SHA: $PREV_SHA"
if [ "$CURR_SHA" != "$PREV_SHA" ]; then
echo "new_commit=true" >> $GITHUB_OUTPUT
echo "New commit detected!"
else
echo "new_commit=false" >> $GITHUB_OUTPUT
echo "No new commits"
fi
- name: Update SHA file in sha branch
if: steps.compare.outputs.new_commit == 'true'
run: |
git checkout sha 2>/dev/null || git checkout --orphan sha
if [ ! -f "latest_sha.txt" ]; then
git rm -rf . 2>/dev/null || true
fi
echo "${{ steps.get_sha.outputs.sha }}" > latest_sha.txt
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add latest_sha.txt
git commit -m "Update SukiSU latest SHA to ${{ steps.get_sha.outputs.sha }}" || exit 0
git push origin sha
# - name: Trigger test_release.yml workflow
# if: steps.compare.outputs.new_commit == 'true'
# run: |
# curl -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# https://api.github.com/repos/${{ github.repository }}/actions/workflows/test_release.yml/dispatches \
# -d '{
# "ref": "dev",
# "inputs": {
# "make_release": "true",
# "kernelsu_variant": "SukiSU",
# "kernelsu_branch": "Stable(标准)",
# "version": "",
# "use_zram": "false",
# "use_bbg": "true",
# "use_kpm": "true",
# "get_manager": "true"
# }
# }'