diff --git a/.github/workflows/trigger-merge-to-downstream.yml b/.github/workflows/trigger-merge-to-downstream.yml new file mode 100644 index 0000000000..70073cf3ca --- /dev/null +++ b/.github/workflows/trigger-merge-to-downstream.yml @@ -0,0 +1,24 @@ +name: trigger-merge-to-downstream + +on: + push: + branches: + - main + - release/** + +permssions: + contents: read + +jobs: + trigger-merge: + if: github.repository == 'hashicorp/boundary' + runs-on: ${{ fromJSON(vars.RUNNER) }} + env: + DOWNSTREAM_SLUG: ${{ vars.DOWNSTREAM_SLUG }} + DOWNSTREAM_TOK: ${{ secrets.DOWNSTREAM_TOK }} + DOWNSTREAM_WORKFLOW: ${{ vars.DOWNSTREAM_WORKFLOW }} + steps: + - uses: actions/checkout@v3 + - name: Trigger Merge + run: | + ./scripts/trigger-merge-to-downstream-gha ${{ github.ref_name }} diff --git a/scripts/trigger-merge-to-downstream-gha b/scripts/trigger-merge-to-downstream-gha new file mode 100755 index 0000000000..1ad38a538d --- /dev/null +++ b/scripts/trigger-merge-to-downstream-gha @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +BRANCH=${1} + +if [[ -z "${BRANCH}" ]]; then + echo "skipping no branch specified" + exit 0 +fi + +if [[ -z "${DOWNSTREAM_SLUG}" ]]; then + echo "skipping, no downstream" + exit 0 +fi + +if [[ -z ${DOWNSTREAM_TOK} ]]; then + exit 0 +fi + +if [[ -z ${DOWNSTREAM_WORKFLOW} ]]; then + echo "skipping, no downstream workflow" + exit 0 +fi + +curl \ + --silent \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${DOWNSTREAM_TOK}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/hashicorp/boundary-${DOWNSTREAM_SLUG}/actions/workflows/${DOWNSTREAM_WORKFLOW}/dispatches" \ + -d @- << EOF +{ + "ref": "${BRANCH}", + "inputs": { + "from-branch": "${BRANCH}", + "to-branch": "${BRANCH}" + } +} +EOF