Skip to content

Commit

Permalink
Update branch name for github action
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemWttJ committed Jul 17, 2024
1 parent d98409d commit 90c5ba2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/demo-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Demo link

on:
pull_request_target:
types: [opened]
types: [opened, synchronize]

jobs:
add_demo_link:
Expand All @@ -13,16 +13,24 @@ jobs:
permissions:
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up GitHub context
id: context
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | sed 's/[^[:alnum:]-]/-/g' | tr '[:upper:]' '[:lower:]' | cut -c -63)" >> $GITHUB_ENV
- name: Update PR description
uses: actions/github-script@v6
with:
script: |
const branchName = process.env.BRANCH_NAME;
const pullRequestId = context.payload.pull_request.number
const pullRequestBranch = context.payload.pull_request.head.ref
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestId,
body: `👀 [Visit Preview](https://${pullRequestBranch}.preprod.welcome-ui.com)`
body: `👀 [Visit Preview](https://${branchName}.preprod.welcome-ui.com)`
});

0 comments on commit 90c5ba2

Please sign in to comment.