Skip to content

Commit edd0cfd

Browse files
authored
escape special characters on PR title
1 parent 704f75d commit edd0cfd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

.github/workflows/PSDB-amd-staging.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,18 @@ jobs:
4040
- name: Pull container image
4141
run: docker pull "${{env.CONTAINER_IMAGE}}"
4242

43-
43+
- name: Escape pull request title
44+
run: |
45+
import json
46+
import os
47+
import shlex
48+
with open('${{ github.event_path }}') as fh:
49+
event = json.load(fh)
50+
escaped = event['pull_request']['title']
51+
with open(os.environ['GITHUB_ENV'], 'a') as fh:
52+
print(f'PR_TITLE={escaped}', file=fh)
53+
shell: python3 {0}
54+
4455
- name: Run container
4556
run: |
4657
docker run -d --name "${{env.CONTAINER_NAME}}" $CONTAINER_IMAGE sleep infinity
@@ -85,7 +96,7 @@ jobs:
8596
if: steps.check_changes.outcome != 'failure'
8697
run: |
8798
echo "--Running jenkins_api.py with input sha - $input_sha for pull request - $input_pr_url"
88-
docker exec -e JENKINS_URL=${{secrets.CI_JENKINS_URL}} -e GITHUB_PAT=${{secrets.CI_GITHUB_TOKEN}} "${{env.CONTAINER_NAME}}" /bin/bash -c "python3 jenkins_api.py -s \"${JENKINS_URL}\" -jn \"${pipeline_name}\" -ghr \"${GITHUB_REPOSITORY}\" -ghsha \"${input_sha}\" -ghprn \"${input_pr_num}\" -ghpru \"${input_pr_url}\" -ghprt '${input_pr_title}' -ghpat=\"${svc_acc_org_secret}\""
99+
docker exec -e JENKINS_URL=${{secrets.CI_JENKINS_URL}} -e GITHUB_PAT=${{secrets.CI_GITHUB_TOKEN}} "${{env.CONTAINER_NAME}}" /bin/bash -c "python3 jenkins_api.py -s \"${JENKINS_URL}\" -jn \"${pipeline_name}\" -ghr \"${GITHUB_REPOSITORY}\" -ghsha \"${input_sha}\" -ghprn \"${input_pr_num}\" -ghpru \"${input_pr_url}\" -ghprt '${PR_TITLE}' -ghpat=\"${svc_acc_org_secret}\""
89100
90101
- name: Stop and remove container
91102
if: always()

0 commit comments

Comments
 (0)