|
| 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 | + 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 "$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 |
0 commit comments