Skip to content

Commit

Permalink
Merge branch 'master' into DOP-3911
Browse files Browse the repository at this point in the history
  • Loading branch information
branberry authored Sep 6, 2023
2 parents a089ede + 3d7fa56 commit 80cab7e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
14 changes: 14 additions & 0 deletions .github/scripts/webhook-pr-comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require('fs');
const path = require('path');
module.exports = () => {
try {
const outputsFile = fs.readFileSync('cdk-infra/outputs.json').toString();
const outputs = JSON.parse(outputsFile);

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', error);
return '';
}
};
20 changes: 16 additions & 4 deletions .github/workflows/deploy-feature-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ on:
types:
- opened
- reopened

name: Initial Feature Branch Deploy
jobs:
deploy:
permissions: write-all
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand All @@ -28,5 +27,18 @@ jobs:
cd cdk-infra/
npm ci
npm run deploy:feature -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} --outputs-file outputs.json
- name: Display resource URLs
run: cat cdk-infra/outputs.json
- 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()
result-encoding: string
- name: Comment on PR
if: steps.webhook.outputs.result != ''
run: gh pr comment ${{github.event.number}} --body "The URL for your feature branch webhook is ${{steps.webhook.outputs.result}}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 80cab7e

Please sign in to comment.