[ads] Add search result ad clicked InfoBar #5916
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
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:?}"; } | |
has_label() { gh pr view "${PR_NUMBER:?}" -R "${GITHUB_REPOSITORY:?}" --json labels -q '.labels[].name'|grep -qxF chromium-version-mismatch; } | |
label() { gh pr edit "${PR_NUMBER:?}" -R "${GITHUB_REPOSITORY:?}" "--${1:?}-label" chromium-version-mismatch >/dev/null; } | |
comment() { | |
local -r comment="Chromium major version is behind target branch ($pr_ver vs $target_ver). Please rebase." | |
gh pr comment "${PR_NUMBER:?}" -R "${GITHUB_REPOSITORY:?}" -b "${comment:?}" | |
} | |
success() { status notice "${1:?}: CI ✅ | Merge ✅"; label remove; } | |
failure() { | |
case "${1:?}" in | |
runci) ci=✅; label remove;; | |
*) has_label || comment; 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 |