Skip to content

Commit

Permalink
[FEATURE]: Add env for branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
branberry committed Aug 31, 2023
1 parent abf051c commit cff1e72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions .github/scripts/webhook-pr-comment.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/deploy-feature-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 != ''
Expand Down

0 comments on commit cff1e72

Please sign in to comment.