Skip to content

Commit 9d01344

Browse files
committed
feat: add upstream sysroot_script monitoring
1 parent fd0abf8 commit 9d01344

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Check Upstream Sysroot Updates
2+
3+
description: |
4+
This workflow runs every two weeks, checks our sysroot scripts against Chromium's
5+
at build/linux/sysroot_scripts and opens an issue if there are any new changes.
6+
7+
on:
8+
schedule:
9+
- cron: "0 0 1,15 * *"
10+
workflow_dispatch:
11+
inputs:
12+
current-sha:
13+
type: string
14+
description: 'Current SHA for build/linux/sysroot_scripts'
15+
required: true
16+
upstream-sha:
17+
type: string
18+
description: 'Upstream SHA for build/linux/sysroot_scripts'
19+
required: true
20+
21+
jobs:
22+
check-upstream-sysroot:
23+
permissions:
24+
issues: write
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Fetch Current SHA
28+
shell: bash
29+
run: |
30+
if [ -n "${{ github.event.inputs.current-sha }}" ]; then
31+
CURRENT_SHA="${{ github.event.inputs.current-sha }}"
32+
else
33+
if [ -f current-sha.json ]; then
34+
CURRENT_SHA=$(jq -r '.sha' current-sha.json)
35+
else
36+
echo "No current SHA provided and current-sha.json not found."
37+
exit 1
38+
fi
39+
fi
40+
echo "CURRENT_SHA=${CURRENT_SHA}" >> $GITHUB_ENV
41+
- name: Fetch latest upstream SHA
42+
shell: bash
43+
run: |
44+
if [ -n "${{ github.event.inputs.upstream-sha }}" ]; then
45+
UPSTREAM_SHA="${{ github.event.inputs.upstream-sha }}"
46+
else
47+
UPSTREAM_SHA=$(curl -s "https://api.github.com/repos/chromium/chromium/commits?path=build/linux/sysroot_scripts&per_page=1" | jq -r '.[0].sha')
48+
fi
49+
echo "UPSTREAM_SHA=${UPSTREAM_SHA}" >> $GITHUB_ENV
50+
- name: Compare current SHA with upstream SHA
51+
shell: bash
52+
run: |
53+
if [ "${{ env.CURRENT_SHA }}" == "${{ env.UPSTREAM_SHA }}" ]; then
54+
echo "No changes found - sysroot scripts are up to date!"
55+
else
56+
curl -s "https://api.github.com/repos/chromium/chromium/commits?path=build/linux/sysroot_scripts&per_page=20" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" > commits.json
57+
58+
COMMITS=$(
59+
jq -r --arg base_sha "${{ env.CURRENT_SHA }}" '
60+
([.[].sha] | index($base_sha) // length) as $idx |
61+
.[0:$idx] | .[] |
62+
"- [`\(.sha[0:7])`](\(.html_url)) \(.commit.message | split("\n")[0])"
63+
' commits.json
64+
)
65+
66+
ISSUE_BODY=$(cat <<EOF
67+
### Upstream sysroot scripts have been updated
68+
69+
Commits between \`${CURRENT_SHA:0:7}\` and \`${UPSTREAM_SHA:0:7}\`:
70+
71+
${COMMITS}
72+
73+
Please review these changes and update our scripts accordingly.
74+
EOF
75+
)
76+
77+
BODY_JSON=$(jq -n --arg body "$ISSUE_BODY" --arg title "Upstream sysroot scripts have changed" '{title: $title, body: $body}')
78+
79+
curl -X POST \
80+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
81+
-H "Accept: application/vnd.github.v3+json" \
82+
-H "Content-Type: application/json" \
83+
-d "$BODY_JSON" \
84+
"https://api.github.com/repos/${{ github.repository }}/issues"
85+
fi

current-sha.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"sha": "082a46c99411023b97fae0476b526b54ff98aa3d"
3+
}

0 commit comments

Comments
 (0)