Skip to content

Commit

Permalink
workflows: Create issue if KMS test fails
Browse files Browse the repository at this point in the history
Since the tests run on push, it's not easy to notice a failure.
File an issue if it happens.
  • Loading branch information
jku committed Nov 30, 2022
1 parent 3dce6f4 commit 2f0df68
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test-kms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:

permissions:
id-token: 'write' # for OIDC auth for GCP authentication
issues: 'write' # for filing an issue on failure

steps:
- name: Checkout securesystemslib
Expand All @@ -36,3 +37,25 @@ jobs:
service_account: securesystemslib@python-tuf-kms.iam.gserviceaccount.com

- run: tox -e kms

- name: File an issue on failure
if: ${{ failure() }}
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0
with:
script: |
const repo = context.repo.owner + "/" + context.repo.repo
const issues = await github.rest.search.issuesAndPullRequests({
q: "KMS+tests+failed+in:title+state:open+type:issue+repo:" + repo,
})
if (issues.data.total_count > 0) {
console.log("Issue open already, not creating.")
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "KMS tests failed",
body: "Hey, it seems KMS tests have failed, please see - [workflow run](" +
"https://github.com/" + repo + "/actions/runs/" + context.runId + ")"
})
console.log("New issue created.")
}

0 comments on commit 2f0df68

Please sign in to comment.