From 645d35ca9a0efac5b934de46389d58d8ddca2dbc Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 27 Jan 2025 12:18:12 -0300 Subject: [PATCH] Add skip-cache input to Prismic deploy workflow and update webhook handler --- .github/workflows/prismic-deploy.yml | 23 ++++++++++++++----- .../netlify/functions/prismicWebhook.ts | 9 ++++---- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/prismic-deploy.yml b/.github/workflows/prismic-deploy.yml index aaf11f03ca..0d56aac1a6 100644 --- a/.github/workflows/prismic-deploy.yml +++ b/.github/workflows/prismic-deploy.yml @@ -3,6 +3,11 @@ name: Prismic Deploy Trigger on: workflow_dispatch: inputs: + skip-cache: + description: "Skip Cache" + required: true + default: true + type: boolean environment: description: "Environment to deploy (e.g., staging or production)" required: true @@ -11,10 +16,10 @@ on: description: "Commit SHA to deploy" required: false netlify-alias: - description: "Netlify alias" + description: "Netlify alias for the deployment" required: false cache-modifier: - description: "Cache modifier" + description: "Cache modifier for build" required: false repository_dispatch: @@ -22,15 +27,21 @@ on: - prismic-webhook jobs: + cache-modifier: + uses: ./.github/workflows/cache-modifier.yml + with: + skip-cache: ${{ github.event.inputs.skip-cache }} + call-deploy: uses: ./.github/workflows/deploy.yml + needs: [cache-modifier] secrets: inherit permissions: pull-requests: write with: - environment: ${{ github.event.client_payload.environment || 'staging' }} - sha: ${{ github.event.client_payload.sha || github.sha }} + environment: ${{ github.event.inputs.environment || github.event.client_payload.environment || 'staging' }} + sha: ${{ github.event.inputs.sha || github.event.client_payload.sha || github.sha }} netlify-context: production - netlify-alias: ${{ github.event.client_payload.netlify_alias || '' }} + netlify-alias: ${{ github.event.inputs.netlify_alias || github.event.client_payload.netlify_alias || '' }} runner-label: ${{ vars.STAGING_RUNNER_LABEL }} - cache-modifier: ${{ github.event.client_payload.cache_modifier || 'default' }} + cache-modifier: ${{ needs.cache-modifier.outputs.cache-modifier }} \ No newline at end of file diff --git a/site/gatsby-site/netlify/functions/prismicWebhook.ts b/site/gatsby-site/netlify/functions/prismicWebhook.ts index a4dca13807..5523422025 100644 --- a/site/gatsby-site/netlify/functions/prismicWebhook.ts +++ b/site/gatsby-site/netlify/functions/prismicWebhook.ts @@ -33,13 +33,12 @@ exports.handler = async (event) => { await axios.post( `https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/actions/workflows/prismic-deploy.yml/dispatches`, { - event_type: `prismic-deploy`, - client_payload: { - netlify_alias: `prismic-${GITHUB_BRANCH}-deploy`, - cache_modifier: "default", + inputs: { + "netlify-alias": `prismic-${GITHUB_BRANCH}-deploy`, environment: GITHUB_BRANCH, + "skip-cache": true, }, - ref: "feature/prismic-webhook", + ref: "main", }, { headers: {