Skip to content

Commit

Permalink
fix(comment-deploy-link): do not break when a single quote is on title (
Browse files Browse the repository at this point in the history
#64)

This commit fixes the GitHub Action so that it prevents that a pull
request title containing the ` character breaks.

This is fixed by reading these values (branch and pr title) as strings
from environment variables instead of interpolating these in the script,
as recommented by
https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable

NOJIRA-123
  • Loading branch information
gomezjdaniel authored Sep 4, 2023
1 parent 4c121d1 commit 45640b2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/comment-deploy-link.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Get deploy link(s)
uses: actions/github-script@v6
id: set-result
env:
PR_TITLE: ${{ github.event.pull_request.title }}
BRANCH_NAME: ${{ github.head_ref }}
with:
script: |
const getJiraId = (text) => {
Expand All @@ -47,8 +50,8 @@ jobs:
}
const references = new Set()
const prTitle = `${{ github.event.pull_request.title }}`
const branchName = `${{ github.head_ref }}`
const prTitle = process.env.PR_TITLE
const branchName = process.env.BRANCH_NAME
const prTitleJiraId = getJiraId(prTitle)
const branchNameJiraId = getJiraId(branchName)
Expand Down

0 comments on commit 45640b2

Please sign in to comment.