Skip to content

wknapik generic testing 03 #1

wknapik generic testing 03

wknapik generic testing 03 #1

name: Rerun Compare Chromium versions
on:
pull_request:
branches:
- master
- '[0-9]+.[0-9]+.x'
paths:
- package.json
types:
- closed
permissions:
pull-requests: write
jobs:
rerun-compare-chromium-versions:
# TODO: uncomment
#if: github.event.pull_request.merged == 'true'
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
steps:
- run: |
shopt -s inherit_errexit
# TODO: remove -x
set -xeEo pipefail
chromium_ver() { curl -fsS "https://raw.githubusercontent.com/${GITHUB_REPOSITORY:?}/${1:?}/package.json"|jq -r .config.projects.chrome.tag; }
# TODO: Replace PR_SHA with GITHUB_HEAD_REF here and in compare-chromium-version
pr_ver="$(chromium_ver "${PR_SHA:?}")"
# TODO: this will need to be a sha
target_ver="$(chromium_ver "${GITHUB_BASE_REF:?}")"
if [[ "${pr_ver%%.*}" != "${target_ver%%.*}" ]]; then
while read -r pr_number head_sha; do
run_id="$(gh api "/repos/$GITHUB_REPOSITORY/actions/workflows/compare-chromium-versions.yml/runs?head_sha=${head_sha:?}" -q '.workflow_runs[0].id')"
# TODO: remove echo
echo gh -R "$GITHUB_REPOSITORY" run rerun "${run_id:?}"
done < <(gh -R "$GITHUB_REPOSITORY" pr list --state open --base "$GITHUB_BASE_REF" --json number,headRefOid -q '.[]|"\(.number)\t\(.headRefOid)"')
fi