From 4acd72cd17585f5abc532d6e11dc5e92311db8db Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 16 Nov 2026 09:25:00 +1100 Subject: [PATCH 1/5] [#3336] Signed the Lagoon PR closure webhook with 'LAGOON_WEBHOOK_TOKEN' and switched to the 'webhook.amazeeio.cloud' endpoint. --- .github/workflows/close-pull-request.yml | 28 +++++++++++++++++++--- .vortex/docs/content/deployment/lagoon.mdx | 26 ++++++++++++++++---- .vortex/docs/content/installation.mdx | 8 +++++-- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/.github/workflows/close-pull-request.yml b/.github/workflows/close-pull-request.yml index e01d1aff38..7212341bfe 100644 --- a/.github/workflows/close-pull-request.yml +++ b/.github/workflows/close-pull-request.yml @@ -11,18 +11,40 @@ on: jobs: remove_lagoon_environment: + #;< VORTEX_DEV + # The template repository has no Lagoon project and no webhook token. + if: ${{ github.repository != 'drevops/vortex' }} + #;> VORTEX_DEV runs-on: ubuntu-latest permissions: contents: read steps: - name: Remove environment after a PR is closed run: | - cat "$GITHUB_EVENT_PATH" | curl \ + if [ -z "${LAGOON_WEBHOOK_TOKEN}" ]; then echo "LAGOON_WEBHOOK_TOKEN secret is not set."; exit 1; fi + + # Lagoon verifies the signature as GitHub webhooks do, so sign the + # exact bytes sent as the body. + signature_sha256="$(openssl dgst -sha256 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + signature_sha1="$(openssl dgst -sha1 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + + status=0 + response="$(curl \ + --silent \ + --show-error \ + --fail-with-body \ -X POST \ --header "Content-Type: application/json" \ --header "X-GitHub-Delivery: ${RUNNER_TRACKING_ID:7}" \ --header "X-GitHub-Event: pull_request" \ - --data-binary @- \ - "${LAGOON_WEBHOOK_ENDPOINT:-https://hooks.lagoon.amazeeio.cloud/}" + --header "X-Hub-Signature-256: sha256=${signature_sha256}" \ + --header "X-Hub-Signature: sha1=${signature_sha1}" \ + --data-binary @"$GITHUB_EVENT_PATH" \ + "${LAGOON_WEBHOOK_ENDPOINT:-https://webhook.amazeeio.cloud/}")" || status=$? + echo "${response}" + + # Lagoon answers a rejected webhook with HTTP 200 and an error body. + if [ "${status}" != "0" ] || echo "${response}" | grep -q '"error"'; then exit 1; fi env: LAGOON_WEBHOOK_ENDPOINT: ${{ vars.LAGOON_WEBHOOK_ENDPOINT }} + LAGOON_WEBHOOK_TOKEN: ${{ secrets.LAGOON_WEBHOOK_TOKEN }} diff --git a/.vortex/docs/content/deployment/lagoon.mdx b/.vortex/docs/content/deployment/lagoon.mdx index 4eeacdd182..c2305e7a01 100644 --- a/.vortex/docs/content/deployment/lagoon.mdx +++ b/.vortex/docs/content/deployment/lagoon.mdx @@ -168,13 +168,29 @@ types](https://docs.lagoon.sh/concepts-advanced/environment-types/). On GitHub, the shipped `.github/workflows/close-pull-request.yml` workflow runs when a pull request closes. The workflow forwards the event to the Lagoon webhook endpoint, so Lagoon removes the pull request's environment. -The endpoint defaults to `https://hooks.lagoon.amazeeio.cloud/`. To use -another Lagoon instance, set the `LAGOON_WEBHOOK_ENDPOINT` repository -variable. +Lagoon accepts only webhooks signed with the project's webhook token. The +workflow signs the event with the `LAGOON_WEBHOOK_TOKEN` repository secret. + +To add the secret: + +1. In the Lagoon UI, copy the **Webhook token** value from the project's + **Details** page. For a polysite, copy the organization's webhook token + instead. +2. In GitHub, add the value under + **Settings > Secrets and variables > Actions** as the + `LAGOON_WEBHOOK_TOKEN` repository secret. + +When the secret is missing, the workflow fails with +`LAGOON_WEBHOOK_TOKEN secret is not set.`. The workflow also fails when +Lagoon rejects the request, and it prints Lagoon's response on every run. + +The endpoint defaults to `https://webhook.amazeeio.cloud/`. To use another +Lagoon instance, set the `LAGOON_WEBHOOK_ENDPOINT` repository variable. The installer keeps this workflow for CircleCI projects too, so the -workflow still runs if GitHub Actions is enabled for the repository. The -CircleCI config has no step that removes pull request environments. +workflow still runs if GitHub Actions is enabled for the repository. Add +the `LAGOON_WEBHOOK_TOKEN` secret to such a repository too. The CircleCI +config has no step that removes pull request environments. ## See also diff --git a/.vortex/docs/content/installation.mdx b/.vortex/docs/content/installation.mdx index aaedc7e28d..e5d43dba28 100644 --- a/.vortex/docs/content/installation.mdx +++ b/.vortex/docs/content/installation.mdx @@ -287,9 +287,13 @@ To set up GitHub Actions: secret too, for database fetches. With separate keys, use the read-only key. Acquia fetches the database through the Acquia Cloud API, so it needs no such secret. -4. On Acquia, add the API key and secret from [step 6](#6-set-up-hosting) +4. On Lagoon, add the project's webhook token as the `LAGOON_WEBHOOK_TOKEN` + secret, so Lagoon removes a pull request's environment when the pull + request closes. [Lagoon deployment](/docs/deployment/lagoon#environments) + says where to find the token. +5. On Acquia, add the API key and secret from [step 6](#6-set-up-hosting) as the `VORTEX_ACQUIA_KEY` and `VORTEX_ACQUIA_SECRET` repository secrets. -5. On Acquia, add these 2 variables under +6. On Acquia, add these 2 variables under **Settings > Secrets and variables > Actions > Variables**: - `VORTEX_DEPLOY_ARTIFACT_GIT_REMOTE`: your application's Git repository URL From 8001b05f8ed82f408b4604e9462f41935341e246 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 16 Nov 2026 09:29:32 +1100 Subject: [PATCH 2/5] Updated snapshots. --- .../.github/workflows/close-pull-request.yml | 24 ++++++++++++++++--- .../.github/workflows/close-pull-request.yml | 24 ++++++++++++++++--- .../.github/workflows/close-pull-request.yml | 24 ++++++++++++++++--- .../.github/workflows/close-pull-request.yml | 24 ++++++++++++++++--- .../.github/workflows/close-pull-request.yml | 24 ++++++++++++++++--- 5 files changed, 105 insertions(+), 15 deletions(-) diff --git a/.vortex/installer/tests/Fixtures/handler_process/hosting_lagoon/.github/workflows/close-pull-request.yml b/.vortex/installer/tests/Fixtures/handler_process/hosting_lagoon/.github/workflows/close-pull-request.yml index e01d1aff38..22f12ed8a6 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/hosting_lagoon/.github/workflows/close-pull-request.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/hosting_lagoon/.github/workflows/close-pull-request.yml @@ -17,12 +17,30 @@ jobs: steps: - name: Remove environment after a PR is closed run: | - cat "$GITHUB_EVENT_PATH" | curl \ + if [ -z "${LAGOON_WEBHOOK_TOKEN}" ]; then echo "LAGOON_WEBHOOK_TOKEN secret is not set."; exit 1; fi + + # Lagoon verifies the signature as GitHub webhooks do, so sign the + # exact bytes sent as the body. + signature_sha256="$(openssl dgst -sha256 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + signature_sha1="$(openssl dgst -sha1 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + + status=0 + response="$(curl \ + --silent \ + --show-error \ + --fail-with-body \ -X POST \ --header "Content-Type: application/json" \ --header "X-GitHub-Delivery: ${RUNNER_TRACKING_ID:7}" \ --header "X-GitHub-Event: pull_request" \ - --data-binary @- \ - "${LAGOON_WEBHOOK_ENDPOINT:-https://hooks.lagoon.amazeeio.cloud/}" + --header "X-Hub-Signature-256: sha256=${signature_sha256}" \ + --header "X-Hub-Signature: sha1=${signature_sha1}" \ + --data-binary @"$GITHUB_EVENT_PATH" \ + "${LAGOON_WEBHOOK_ENDPOINT:-https://webhook.amazeeio.cloud/}")" || status=$? + echo "${response}" + + # Lagoon answers a rejected webhook with HTTP 200 and an error body. + if [ "${status}" != "0" ] || echo "${response}" | grep -q '"error"'; then exit 1; fi env: LAGOON_WEBHOOK_ENDPOINT: ${{ vars.LAGOON_WEBHOOK_ENDPOINT }} + LAGOON_WEBHOOK_TOKEN: ${{ secrets.LAGOON_WEBHOOK_TOKEN }} diff --git a/.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___lagoon/.github/workflows/close-pull-request.yml b/.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___lagoon/.github/workflows/close-pull-request.yml index e01d1aff38..22f12ed8a6 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___lagoon/.github/workflows/close-pull-request.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___lagoon/.github/workflows/close-pull-request.yml @@ -17,12 +17,30 @@ jobs: steps: - name: Remove environment after a PR is closed run: | - cat "$GITHUB_EVENT_PATH" | curl \ + if [ -z "${LAGOON_WEBHOOK_TOKEN}" ]; then echo "LAGOON_WEBHOOK_TOKEN secret is not set."; exit 1; fi + + # Lagoon verifies the signature as GitHub webhooks do, so sign the + # exact bytes sent as the body. + signature_sha256="$(openssl dgst -sha256 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + signature_sha1="$(openssl dgst -sha1 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + + status=0 + response="$(curl \ + --silent \ + --show-error \ + --fail-with-body \ -X POST \ --header "Content-Type: application/json" \ --header "X-GitHub-Delivery: ${RUNNER_TRACKING_ID:7}" \ --header "X-GitHub-Event: pull_request" \ - --data-binary @- \ - "${LAGOON_WEBHOOK_ENDPOINT:-https://hooks.lagoon.amazeeio.cloud/}" + --header "X-Hub-Signature-256: sha256=${signature_sha256}" \ + --header "X-Hub-Signature: sha1=${signature_sha1}" \ + --data-binary @"$GITHUB_EVENT_PATH" \ + "${LAGOON_WEBHOOK_ENDPOINT:-https://webhook.amazeeio.cloud/}")" || status=$? + echo "${response}" + + # Lagoon answers a rejected webhook with HTTP 200 and an error body. + if [ "${status}" != "0" ] || echo "${response}" | grep -q '"error"'; then exit 1; fi env: LAGOON_WEBHOOK_ENDPOINT: ${{ vars.LAGOON_WEBHOOK_ENDPOINT }} + LAGOON_WEBHOOK_TOKEN: ${{ secrets.LAGOON_WEBHOOK_TOKEN }} diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_lagoon/.github/workflows/close-pull-request.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_lagoon/.github/workflows/close-pull-request.yml index e01d1aff38..22f12ed8a6 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_lagoon/.github/workflows/close-pull-request.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_lagoon/.github/workflows/close-pull-request.yml @@ -17,12 +17,30 @@ jobs: steps: - name: Remove environment after a PR is closed run: | - cat "$GITHUB_EVENT_PATH" | curl \ + if [ -z "${LAGOON_WEBHOOK_TOKEN}" ]; then echo "LAGOON_WEBHOOK_TOKEN secret is not set."; exit 1; fi + + # Lagoon verifies the signature as GitHub webhooks do, so sign the + # exact bytes sent as the body. + signature_sha256="$(openssl dgst -sha256 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + signature_sha1="$(openssl dgst -sha1 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + + status=0 + response="$(curl \ + --silent \ + --show-error \ + --fail-with-body \ -X POST \ --header "Content-Type: application/json" \ --header "X-GitHub-Delivery: ${RUNNER_TRACKING_ID:7}" \ --header "X-GitHub-Event: pull_request" \ - --data-binary @- \ - "${LAGOON_WEBHOOK_ENDPOINT:-https://hooks.lagoon.amazeeio.cloud/}" + --header "X-Hub-Signature-256: sha256=${signature_sha256}" \ + --header "X-Hub-Signature: sha1=${signature_sha1}" \ + --data-binary @"$GITHUB_EVENT_PATH" \ + "${LAGOON_WEBHOOK_ENDPOINT:-https://webhook.amazeeio.cloud/}")" || status=$? + echo "${response}" + + # Lagoon answers a rejected webhook with HTTP 200 and an error body. + if [ "${status}" != "0" ] || echo "${response}" | grep -q '"error"'; then exit 1; fi env: LAGOON_WEBHOOK_ENDPOINT: ${{ vars.LAGOON_WEBHOOK_ENDPOINT }} + LAGOON_WEBHOOK_TOKEN: ${{ secrets.LAGOON_WEBHOOK_TOKEN }} diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_lagoon/.github/workflows/close-pull-request.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_lagoon/.github/workflows/close-pull-request.yml index e01d1aff38..22f12ed8a6 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_lagoon/.github/workflows/close-pull-request.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_lagoon/.github/workflows/close-pull-request.yml @@ -17,12 +17,30 @@ jobs: steps: - name: Remove environment after a PR is closed run: | - cat "$GITHUB_EVENT_PATH" | curl \ + if [ -z "${LAGOON_WEBHOOK_TOKEN}" ]; then echo "LAGOON_WEBHOOK_TOKEN secret is not set."; exit 1; fi + + # Lagoon verifies the signature as GitHub webhooks do, so sign the + # exact bytes sent as the body. + signature_sha256="$(openssl dgst -sha256 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + signature_sha1="$(openssl dgst -sha1 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + + status=0 + response="$(curl \ + --silent \ + --show-error \ + --fail-with-body \ -X POST \ --header "Content-Type: application/json" \ --header "X-GitHub-Delivery: ${RUNNER_TRACKING_ID:7}" \ --header "X-GitHub-Event: pull_request" \ - --data-binary @- \ - "${LAGOON_WEBHOOK_ENDPOINT:-https://hooks.lagoon.amazeeio.cloud/}" + --header "X-Hub-Signature-256: sha256=${signature_sha256}" \ + --header "X-Hub-Signature: sha1=${signature_sha1}" \ + --data-binary @"$GITHUB_EVENT_PATH" \ + "${LAGOON_WEBHOOK_ENDPOINT:-https://webhook.amazeeio.cloud/}")" || status=$? + echo "${response}" + + # Lagoon answers a rejected webhook with HTTP 200 and an error body. + if [ "${status}" != "0" ] || echo "${response}" | grep -q '"error"'; then exit 1; fi env: LAGOON_WEBHOOK_ENDPOINT: ${{ vars.LAGOON_WEBHOOK_ENDPOINT }} + LAGOON_WEBHOOK_TOKEN: ${{ secrets.LAGOON_WEBHOOK_TOKEN }} diff --git a/.vortex/installer/tests/Fixtures/handler_process/provision_database_lagoon/.github/workflows/close-pull-request.yml b/.vortex/installer/tests/Fixtures/handler_process/provision_database_lagoon/.github/workflows/close-pull-request.yml index e01d1aff38..22f12ed8a6 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/provision_database_lagoon/.github/workflows/close-pull-request.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/provision_database_lagoon/.github/workflows/close-pull-request.yml @@ -17,12 +17,30 @@ jobs: steps: - name: Remove environment after a PR is closed run: | - cat "$GITHUB_EVENT_PATH" | curl \ + if [ -z "${LAGOON_WEBHOOK_TOKEN}" ]; then echo "LAGOON_WEBHOOK_TOKEN secret is not set."; exit 1; fi + + # Lagoon verifies the signature as GitHub webhooks do, so sign the + # exact bytes sent as the body. + signature_sha256="$(openssl dgst -sha256 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + signature_sha1="$(openssl dgst -sha1 -hmac "${LAGOON_WEBHOOK_TOKEN}" "$GITHUB_EVENT_PATH" | sed 's/^.* //')" + + status=0 + response="$(curl \ + --silent \ + --show-error \ + --fail-with-body \ -X POST \ --header "Content-Type: application/json" \ --header "X-GitHub-Delivery: ${RUNNER_TRACKING_ID:7}" \ --header "X-GitHub-Event: pull_request" \ - --data-binary @- \ - "${LAGOON_WEBHOOK_ENDPOINT:-https://hooks.lagoon.amazeeio.cloud/}" + --header "X-Hub-Signature-256: sha256=${signature_sha256}" \ + --header "X-Hub-Signature: sha1=${signature_sha1}" \ + --data-binary @"$GITHUB_EVENT_PATH" \ + "${LAGOON_WEBHOOK_ENDPOINT:-https://webhook.amazeeio.cloud/}")" || status=$? + echo "${response}" + + # Lagoon answers a rejected webhook with HTTP 200 and an error body. + if [ "${status}" != "0" ] || echo "${response}" | grep -q '"error"'; then exit 1; fi env: LAGOON_WEBHOOK_ENDPOINT: ${{ vars.LAGOON_WEBHOOK_ENDPOINT }} + LAGOON_WEBHOOK_TOKEN: ${{ secrets.LAGOON_WEBHOOK_TOKEN }} From 0e8081b791d48a0668cee49504314b35a3141ce7 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 16 Nov 2026 09:36:59 +1100 Subject: [PATCH 3/5] [#3336] Added the 'LAGOON_WEBHOOK_TOKEN' secret to the CircleCI setup steps. --- .vortex/docs/content/installation.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.vortex/docs/content/installation.mdx b/.vortex/docs/content/installation.mdx index e5d43dba28..fb00d0cea5 100644 --- a/.vortex/docs/content/installation.mdx +++ b/.vortex/docs/content/installation.mdx @@ -334,6 +334,10 @@ To set up CircleCI: URL - `VORTEX_DEPLOY_ARTIFACT_GIT_USER_EMAIL`: the email address for the deployment commits +9. On Lagoon with GitHub Actions enabled for the repository, add the + project's webhook token in GitHub as the `LAGOON_WEBHOOK_TOKEN` secret. + [Lagoon deployment](/docs/deployment/lagoon#environments) says where to + find the token and why the secret is needed. On Lagoon, the pipeline fetches and deploys with the SSH keys you added. From fda695eb35b9d5dc0d79e89383289d8779a07c63 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 16 Nov 2026 09:43:26 +1100 Subject: [PATCH 4/5] [#3336] Added 'polysite' to the docs spelling dictionary. --- .vortex/docs/cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vortex/docs/cspell.json b/.vortex/docs/cspell.json index db7e21a182..bfa984ba3d 100644 --- a/.vortex/docs/cspell.json +++ b/.vortex/docs/cspell.json @@ -86,6 +86,7 @@ "phpcompatibility", "phpspec", "phpstorm", + "polysite", "postbuild", "preboot", "prompty", From 5deee0c7aff06d9883eac4bc136c6e9f354b53fb Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 16 Nov 2026 10:07:39 +1100 Subject: [PATCH 5/5] Re-triggered CI to clear a flaky check.