Skip to content

Commit

Permalink
[FEATURE]: Add try catch and conditional for commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
branberry committed Aug 31, 2023
1 parent 0a2b540 commit 16b5671
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/scripts/webhook-pr-comment.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
const fs = require('fs');

module.exports = ({ github }) => {
const outputsFile = fs.readFileSync('cdk-infra/outputs.json').toString();
const outputs = JSON.parse(outputsFile);
console.log(github.head_ref);
console.log(outputsFile);
const webhook = Object.values(outputs[`auto-builder-stack-enhancedApp-stg-${github.head_ref}-webhooks`])[0];
return webhook;
try {
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];
return webhook;
} catch (error) {
console.log('Error occurred when retrieving Webhook URL');
return '';
}
};
1 change: 1 addition & 0 deletions .github/workflows/deploy-feature-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
return script({context, github})
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 16b5671

Please sign in to comment.