• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: runner-determinator
2
3on:
4  workflow_dispatch:
5  pull_request:
6    branches: [main]
7    paths:
8      - .github/workflows/_runner-determinator.yaml
9      - .github/workflows/_runner_determinator_script_sync.yaml
10      - .github/workflows/scripts/runner_determinator.py
11
12jobs:
13  python-script-sync-check:
14    runs-on: ubuntu-latest
15
16    steps:
17      - uses: actions/checkout@v4
18        with:
19          sparse-checkout: |
20            .github
21
22      - name: Extract the script from runner_determinator
23        run: |
24            # Runner determinator files
25            RUNNER_DETERMINATOR_WORKFLOW_FILE=.github/workflows/_runner-determinator.yml
26            RUNNER_DETERMINATOR_PYTHON_SCRIPT_FILE=.github/scripts/runner_determinator.py
27
28            # Parse the job file, extract the script and run it, up to the final EOF,
29            # to generate the python file in the local folder
30            yq '.jobs.runner-determinator.steps[] | select(.id == "hardcode-script") | .run' \
31                "${RUNNER_DETERMINATOR_WORKFLOW_FILE}" | sed '/^EOF$/q' | bash
32
33            set +e
34            DIFF="$(diff "$(basename ${RUNNER_DETERMINATOR_PYTHON_SCRIPT_FILE})" ${RUNNER_DETERMINATOR_PYTHON_SCRIPT_FILE})"
35            IS_DIFF=$?
36            set -e
37            if [ $IS_DIFF -eq 0 ]; then
38                echo "Scripts are in sync! ^_^";
39            else
40                echo -e "Scripts are *NOT* in sync:\n ${DIFF}";
41                exit 1
42            fi
43