Improve Stackage nightly workflow to automatically create an issue if it fails #1275
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: "Stackage Nightly" | |
on: | |
schedule: | |
- cron: "5 6 * * *" | |
workflow_dispatch: | |
pull_request: | |
push: | |
paths: | |
- ".github/workflows/stackage-nightly.yml" | |
permissions: | |
contents: read | |
issues: write | |
jobs: | |
build: | |
name: "Build (Nightly)" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Clone repository" | |
uses: actions/checkout@v4 | |
- name: "Build using nightly resolver" | |
uses: mbg/actions/stack/[email protected] | |
- name: "Fail on purpose" | |
run: exit 1 | |
- name: "Create issue" | |
if: failure() | |
run: | | |
previous_issue_number=$(gh issue list \ | |
--label "stackage-nightly-failure" \ | |
--json number \ | |
--jq '.[0].number') | |
if [[ -n $previous_issue_number ]]; then | |
# don't create a new issue if there's already one | |
exit 0 | |
fi | |
gh issue create --assignee "mbg" \ | |
--label "stackage-nightly-failure" | |
--title "Stackage Nightly build failed" \ | |
--body "The workflow at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} failed" |