From 704c5b0cd40122d279bf89da089bdc1cf8f023c1 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Tue, 27 Aug 2024 09:08:44 +1200 Subject: [PATCH] MNT Replace CI with patch release dispatcher --- .github/workflows/ci.yml | 41 +++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52bf99d..0c5bbf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,14 +2,41 @@ name: CI on: push: - pull_request: workflow_dispatch: +permissions: {} + jobs: ci: - name: CI - uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 - with: - # There's no actual PHP or JS, despite having phpcs.xml and package.json files. - phplinting: false - js: false + # This repo has no tests and nothing to lint, so we can't use regular CI. + # Instead, just directly dispatch tag release on push, and let that figure it out. + name: Dispatch tag patch release + runs-on: ubuntu-latest + if: github.repository_owner == 'silverstripe' + permissions: + actions: write + env: + GITHUB_REPOSITORY: ${{ github.repository }} + BRANCH: ${{ github.ref_name }} + steps: + + - name: Dispatch tag patch release + shell: bash + id: dispatch-tag-patch-release + run: | + LATEST_LOCAL_SHA=$(git rev-parse HEAD) + echo "LATEST_LOCAL_SHA is $LATEST_LOCAL_SHA" + # https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event + RESP_CODE=$(curl -w %{http_code} -s -L -o __response.json \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ github.token }}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows/tag-patch-release.yml/dispatches \ + -d "{\"ref\":\"$BRANCH\",\"inputs\":{\"latest_local_sha\":\"$LATEST_LOCAL_SHA\"}}" + ) + if [[ $RESP_CODE != "204" ]]; then + echo "Failed to dispatch workflow - HTTP response code was $RESP_CODE" + cat __response.json + exit 1 + fi