summary refs log tree commit diff
path: root/.github/workflows/wait-ofborg.yml
blob: 6ddf00bb1ef5df30afb983bbeb88277703778e83 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: "Wait for ofborg"
on:
  pull_request:
jobs:
  tests:
    runs-on: ubuntu-latest
    steps:
    - name: Wait for ofborg CI
      run: |
        # Wait for ofborg ...
        # eval sometimes takes a bit longer on staging.
        if [[ "$BASE_BRANCH" == "staging" ]]; then
          COUNTDOWN=$((COUNTDOWN*2))
        fi
        # ..in future a better fix would be to make ofborg mark CI as pending right away.
        for i in $(seq "$COUNTDOWN"); do
          res=$(curl --silent \
            -H "Accept: application/vnd.github.antiope-preview+json" \
            -H "Authorization: token ${GITHUB_TOKEN}" \
            "https://api.github.com/repos/NixOS/nixpkgs/commits/${COMMIT}/check-runs" | \
            jq ".check_runs | map(.app) | map(.id) | contains([${OFBORG_APP_ID}])")
          if [[ "$res" == "true" ]]; then
            exit 0
          fi
          sleep 5
          echo "."
        done
        echo "Timeout!"
        exit 1
      # ofborg is not checking forks.
      if: github.repository_owner == 'NixOS'
      env:
        BASE_BRANCH: ${{ github.base_ref }}
        COUNTDOWN: 540 # wait for ~45min...
        GITHUB_TOKEN: ${{ github.token }}
        COMMIT: ${{ github.event.pull_request.head.sha }}
        OFBORG_APP_ID: 20500