Skip to content

Fix site settings #4377

Fix site settings

Fix site settings #4377

name: Compare Chromium versions
on:
pull_request:
types: [opened, reopened, synchronize]
permissions:
pull-requests: write
jobs:
compare-chromium-versions:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
steps:
- name: Check if CI and merge are allowed based on the Chromium version in the target branch
run: |
shopt -s inherit_errexit
set -eEo pipefail
chromium_ver() { curl -fsS "https://raw.githubusercontent.com/${GITHUB_REPOSITORY:?}/${1:?}/package.json"|jq -r .config.projects.chrome.tag; }
pr_ver="$(chromium_ver "${PR_SHA:?}")"
target_ver="$(chromium_ver "${GITHUB_BASE_REF:?}")"
status() { echo "::${1:?}::${2:?}"; echo "$2" >>"${GITHUB_STEP_SUMMARY:?}"; }
label() { gh pr edit "${PR_NUMBER:?}" -R "${GITHUB_REPOSITORY:?}" "--${1:?}-label" chromium-version-mismatch >/dev/null; }
success() { status notice "${1:?}: CI ✅ | Merge ✅"; label remove; }
failure() {
case "${1:?}" in runci) ci=✅; label remove;; *) ci=🚫; label add;; esac
status error "${2:?}: CI $ci | Merge 🚫"
status error "Please rebase."
exit 2
}
echo "::notice::PR branch: ${pr_ver:?}, target branch: ${target_ver:?}"
if [[ "$pr_ver" == "$target_ver" ]]; then
success "Chromium version full match"
elif [[ "$(sort -V <<<"$target_ver"$'\n'"$pr_ver"|tail -n1)" == "$pr_ver" ]]; then
success "Chromium version is newer in the PR"
elif [[ "${pr_ver%%.*}" == "${target_ver%%.*}" ]]; then
success "Chromium major version match"
else
failure blockci "Chromium version mismatch"
fi