Skip to content

Commit d36266e

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

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Check Upstream Sysroot Updates
2+
3+
description: |
4+
This workflow checks our sysroot scripts against Chromium's sysroot scripts
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+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Fetch Current SHA
26+
shell: bash
27+
run: |
28+
if [ -n "${{ github.event.inputs.current-sha }}" ]; then
29+
CURRENT_SHA="${{ github.event.inputs.current-sha }}"
30+
else
31+
if [ -f current-sha.json ]; then
32+
CURRENT_SHA=$(jq -r '.sha' current-sha.json)
33+
else
34+
echo "No current SHA provided and current-sha.json not found."
35+
exit 1
36+
fi
37+
fi
38+
echo "CURRENT_SHA=${CURRENT_SHA}" >> $GITHUB_ENV
39+
- name: Fetch latest upstream SHA
40+
shell: bash
41+
run: |
42+
if [ -n "${{ github.event.inputs.upstream-sha }}" ]; then
43+
UPSTREAM_SHA="${{ github.event.inputs.upstream-sha }}"
44+
else
45+
UPSTREAM_SHA=$(curl -s "https://api.github.com/repos/chromium/chromium/commits?path=build/linux/sysroot_scripts&per_page=1" | jq -r '.[0].sha')
46+
fi
47+
echo "UPSTREAM_SHA=${UPSTREAM_SHA}" >> $GITHUB_ENV
48+
- name: Compare current SHA with upstream SHA
49+
shell: bash
50+
run: |
51+
if [ "${{ env.CURRENT_SHA }}" == "${{ env.UPSTREAM_SHA }}" ]; then
52+
echo "No changes found - sysroot scripts are up to date!"
53+
else
54+
$(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
55+
56+
if [ $? -ne 0 ]; then
57+
echo "Failed to fetch commits."
58+
exit 1
59+
else
60+
echo "Fetched commits successfully."
61+
fi
62+
fi
63+
# COMMITS=$(
64+
# jq -r --arg base_sha "$CURRENT_SHA" '
65+
# ([.[].sha] | index($base_sha) // length) as $idx |
66+
# .[0:$idx] | .[] |
67+
# "- [`\(.sha[0:7])`](\(.html_url)) \(.commit.message | split("\n")[0])"
68+
# ' commits.json
69+
# )
70+
71+
# echo $COMMITS
72+
73+
# ISSUE_BODY=$(cat <<EOF
74+
# ### Upstream sysroot scripts have been updated
75+
76+
# Commits between ${CURRENT_SHA} and ${UPSTREAM_SHA}:
77+
78+
# ${COMMITS}
79+
80+
# Please review these changes and update our scripts accordingly.
81+
# EOF
82+
# )
83+
84+
# echo "HELLO"
85+
# BODY_JSON=$(jq -n --arg body "$ISSUE_BODY" --arg title "Upstream sysroot scripts have changed" '{title: $title, body: $body}')
86+
87+
# curl -X POST \
88+
# -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
89+
# -H "Accept: application/vnd.github.v3+json" \
90+
# -H "Content-Type: application/json" \
91+
# -d "$BODY_JSON" \
92+
# "https://api.github.com/repos/${{ github.repository }}/issues"
93+
# 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)