diff --git a/.github/scripts/webhook-pr-comment.js b/.github/scripts/webhook-pr-comment.js index 1c07daccb..281b841da 100644 --- a/.github/scripts/webhook-pr-comment.js +++ b/.github/scripts/webhook-pr-comment.js @@ -1,14 +1,13 @@ const fs = require('fs'); -const path = require('path'); -module.exports = ({ github }) => { +module.exports = () => { try { - const outputsFile = fs.readFileSync(path.join(process.cwd(), 'cdk-infra/outputs.json')).toString(); + const outputsFile = fs.readFileSync('cdk-infra/outputs.json').toString(); const outputs = JSON.parse(outputsFile); console.log('github', github); console.log(github.head_ref); console.log(outputsFile); - const webhook = Object.values(outputs[`auto-builder-stack-enhancedApp-stg-${github.head_ref}-webhooks`])[0]; + const webhook = Object.values(outputs[`auto-builder-stack-enhancedApp-stg-${process.env.GIT_BRANCH}-webhooks`])[0]; return webhook; } catch (error) { console.log('Error occurred when retrieving Webhook URL'); diff --git a/.github/workflows/deploy-feature-branch.yml b/.github/workflows/deploy-feature-branch.yml index e9ecbe1c7..3ffc81099 100644 --- a/.github/workflows/deploy-feature-branch.yml +++ b/.github/workflows/deploy-feature-branch.yml @@ -30,10 +30,12 @@ jobs: - name: Get Webhook URL uses: actions/github-script@v6 id: webhook + env: + GIT_BRANCH: ${{github.head_ref}} with: script: | const script = require('./.github/scripts/webhook-pr-comment.js'); - return script({context, github}) + return script() result-encoding: string - name: Comment on PR if: steps.webhook.outputs.result != ''