Skip to content

Avoid races in system_tests changing config by making the changes atomic #865

Avoid races in system_tests changing config by making the changes atomic

Avoid races in system_tests changing config by making the changes atomic #865

---
name: Check Design Approved
on:
merge_group:
pull_request_target:
branches: [master, main]
types: [synchronize, opened, reopened, labeled, unlabeled]
permissions:
statuses: write
jobs:
check-design-approved:
name: Check if Design Approved
runs-on: ubuntu-4
steps:
- name: Check if design approved and update status
run: |
set -euo pipefail
repo_url="${{ github.api_url }}/repos/$GITHUB_REPOSITORY"
commit_sha="${{ github.event.pull_request.head.sha || github.sha }}"
status_state="success" # default to success
if [[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "pull_request_target" ]]; then
design_approved='${{ contains(github.event.pull_request.labels.*.name, 'design-approved') }}'
after_next_version='${{ contains(github.event.pull_request.labels.*.name, 'after-next-version') }}'
status_state="pending"
if [[ "$design_approved" == "true" && "$after_next_version" != "true" ]]; then
status_state="success"
fi
fi
curl -sSL --fail-with-body \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"${repo_url}/statuses/$commit_sha" \
-d '{"context":"Design Approved Check","state":"'"$status_state"'"}'