From 68883b6fe834abb1783e62815fdc53a0db893f18 Mon Sep 17 00:00:00 2001 From: Kyle Hensel Date: Sun, 13 Oct 2024 15:58:17 +1100 Subject: [PATCH] add CI script to automatically update a git tag --- .github/workflows/release.yml | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..fc7136ec8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Release + +on: + schedule: + - cron: '0 7 * * 2' + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + + permissions: + checks: read + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Check that the CI is passing + uses: actions/github-script@v7 + with: + script: | + const checks = await github.rest.checks.listForRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: '${{github.event.repository.default_branch}}', + }); + + const isSuccessful = checks.data.check_runs + .filter((run) => run.name !== process.env.GITHUB_JOB) + .every((run) => run.conclusion === 'success'); + + if (!isSuccessful) { + core.error('Not creating a release because the CI is failing.'); + process.exit(1); + } + + - name: Update git tag + uses: EndBug/latest-tag@latest + with: + ref: latest