From 6a4d096d2a85d1e8db4145f32e02cf670b3ddc20 Mon Sep 17 00:00:00 2001 From: Louisa Chu Date: Fri, 23 May 2025 16:06:59 -0700 Subject: [PATCH] update scripts --- .github/scripts/deploy.js | 4 ++-- .github/workflows/deploy.yml | 9 ++++++++- .github/workflows/resuse-deploy.yml | 26 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/resuse-deploy.yml diff --git a/.github/scripts/deploy.js b/.github/scripts/deploy.js index 1d0b76381..91850f34c 100644 --- a/.github/scripts/deploy.js +++ b/.github/scripts/deploy.js @@ -48,7 +48,7 @@ module.exports = async ({ core, changes, deletions, operation, siteEnv, branch, file = file.replace('src/pages/', ''); const theFilePath = `${pathPrefix}/${file}`; - const deleteUrl = `https://admin.hlx.page/live/adobedocs/${edsSiteEnv}/${codeRepoBranch}${theFilePath}`; + const deleteUrl = `https://admin.hlx.page/${operation}/adobedocs/${edsSiteEnv}/${codeRepoBranch}${theFilePath}`; const deleteCmd = `curl -XDELETE -vi ${args} ${deleteUrl}`; @@ -58,7 +58,7 @@ module.exports = async ({ core, changes, deletions, operation, siteEnv, branch, return; } - console.log(`::group:: Deleting ${theFilePath} \n${deleteExecOut} \n::endgroup::`); + console.log(`::group:: Deleting ${operation} on ${theFilePath} \nThe command: ${deleteCmd} \n${deleteExecOut} \n::endgroup::`); }); }); } \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 33b16f015..1961b8453 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -112,7 +112,7 @@ jobs: pathPrefix: "${{ needs.set-state.outputs.path_prefix }}" }); - - name: Deploy to prod + - name: Deploy to prod (Step 1 of 2) if: needs.set-state.outputs.deploy_prod == 'true' && steps.changed-files-specific.outputs.any_modified == 'true' uses: actions/github-script@v7 with: @@ -129,6 +129,13 @@ jobs: pathPrefix: "${{ needs.set-state.outputs.path_prefix }}" }); + - name: Deploy to prod (Step 2 of 2) + if: needs.set-state.outputs.deploy_prod == 'true' && steps.changed-files-specific.outputs.any_modified == 'true' + uses: actions/github-script@v7 + with: + script: | + const script = require('./.github/scripts/deploy.js'); + await script({ core, changes: ${{ steps.changed-files-specific.outputs.all_changed_files }}, diff --git a/.github/workflows/resuse-deploy.yml b/.github/workflows/resuse-deploy.yml new file mode 100644 index 000000000..1bee8dc22 --- /dev/null +++ b/.github/workflows/resuse-deploy.yml @@ -0,0 +1,26 @@ +--- +name: Reuse Deployment +on: + workflow_dispatch: + inputs: + env: + description: "Select environment to deploy to" + type: choice + required: true + default: "stage" + options: + - stage + - prod + baseSha: + description: "Use base SHA commit to deploy from (empty string defaults to last commit before HEAD)" + type: string + required: false + default: "" + +jobs: + reuse_deployment: + name: Reuse Deployment + uses: AdobeDocs/adp-devsite-workflow/.github/workflows/deploy.yml@main + with: + env: ${{ inputs.env }} + baseSha: ${{ inputs.baseSha }}