diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2de8d37979..da16bd8d17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,6 @@ on: tags: - '*' pull_request: - types: [opened, synchronize, reopened, labeled] merge_group: schedule: - cron: '0 7 * * *' # 8AM CET/11PM PT @@ -41,12 +40,18 @@ jobs: steps: - name: Run quick CI? id: set-quick - env: - quick: ${{ - github.event_name == 'pull_request' && !contains( github.event.pull_request.labels.*.name, 'full-ci') - }} + # We do not use github.event.pull_request.labels.*.name here because + # re-running a run does not update that list, and we do want to be able to + # rerun the workflow run after settings the `full-ci` label. run: | - echo "quick=${{env.quick}}" >> "$GITHUB_OUTPUT" + if [ "${{ github.event_name }}" == 'pull_request' ] + then + echo "quick=$(gh api repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls/${{ github.event.pull_request.number }} --jq '.labels | any(.name == "full-ci") | not')" >> "$GITHUB_OUTPUT" + else + echo "quick=false" >> "$GITHUB_OUTPUT" + fi + env: + GH_TOKEN: ${{ github.token }} - name: Configure build matrix id: set-matrix diff --git a/.github/workflows/nix-ci.yml b/.github/workflows/nix-ci.yml index aa9e409b35..c5cdddfefc 100644 --- a/.github/workflows/nix-ci.yml +++ b/.github/workflows/nix-ci.yml @@ -6,7 +6,6 @@ on: tags: - '*' pull_request: - types: [opened, synchronize, reopened, labeled] merge_group: concurrency: diff --git a/.github/workflows/restart-on-label.yml b/.github/workflows/restart-on-label.yml new file mode 100644 index 0000000000..f5a30e225b --- /dev/null +++ b/.github/workflows/restart-on-label.yml @@ -0,0 +1,31 @@ +name: Restart by label +on: + pull_request_target: + types: + - unlabeled + - labeled +jobs: + restart-on-label: + runs-on: ubuntu-latest + if: contains(github.event.label.name, 'full-ci') + steps: + - run: | + # Finding latest CI workflow run on current pull request + # (unfortunately cannot search by PR number, only base branch, + # and that is't even unique given PRs from forks, but the risk + # of confusion is low and the danger is mild) + run_id=$(gh run list -e pull_request -b "$head_ref" --workflow 'CI' --limit 1 \ + --limit 1 --json databaseId --jq '.[0].databaseId') + echo "Run id: ${run_id}" + gh run view "$run_id" + echo "Cancelling (just in case)" + gh run cancel "$run_id" || echo "(failed)" + echo "Waiting for 10s" + sleep 10 + echo "Rerunning" + gh run rerun "$run_id" + shell: bash + env: + head_ref: ${{ github.head_ref }} + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }}