From 8efe686db605ccee6cd01b50f51b59115ac5b3c5 Mon Sep 17 00:00:00 2001 From: mrlutik Date: Fri, 1 Mar 2024 12:37:21 +0100 Subject: [PATCH] feat(release_hook): Add webhook on merge from release to master Passes release version and directed to github api --- .github/workflows/hook.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/hook.yml diff --git a/.github/workflows/hook.yml b/.github/workflows/hook.yml new file mode 100644 index 00000000..dea799d5 --- /dev/null +++ b/.github/workflows/hook.yml @@ -0,0 +1,28 @@ +name: Release Merged Hook + +on: + pull_request: + types: [closed] + branches: + - master + +jobs: + trigger-dispatch: + if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') + runs-on: ubuntu-latest + steps: + - name: Extract Version from Branch Name + id: version-extract + run: echo "version=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV + shell: bash + + - name: Trigger Repository Dispatch Event + env: + VERSION: ${{ env.version }} + run: | + VERSION=${VERSION#"release/"} + curl -X POST -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ + "https://api.github.com/repos/${{ secrets.DISPATCH_OWNER }}/${{ secrets.DISPATCH_REPO }}/dispatches" \ + -d "{\"event_type\":\"release_merged\", \"client_payload\": {\"version\":\"${VERSION}\"}}" +