Skip to content

Commit ca690dd

Browse files
authored
Merge pull request llvm#494 from AMD-Lightning-Internal/amd/dev/sivganes/special-chars-github-action
[CI/CD] handle special characters in PR title
2 parents d61de8c + c2c0704 commit ca690dd

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ jobs:
4646
docker run -d --name "${{env.CONTAINER_NAME}}" $CONTAINER_IMAGE sleep infinity
4747
#docker exec "${{env.CONTAINER_NAME}}" /bin/bash -c "git clone ${{secrets.CI_UTILS_REPO}} ."
4848
docker exec "${{env.CONTAINER_NAME}}" /bin/bash -c "echo 'Running commands inside the container'"
49+
50+
- name: Escape pull request title
51+
run: |
52+
import json
53+
import os
54+
import shlex
55+
with open('${{ github.event_path }}') as fh:
56+
event = json.load(fh)
57+
escaped = event['pull_request']['title']
58+
with open(os.environ['GITHUB_ENV'], 'a') as fh:
59+
print(f'PR_TITLE={escaped}', file=fh)
60+
shell: python3 {0}
4961

5062
- name: Run Jenkins Cancel Script
5163
env:
@@ -79,13 +91,15 @@ jobs:
7991
echo "github.event.pull_request.base.ref is: ${{github.event.pull_request.base.ref}}"
8092
echo "github.event.pull_request.merge_commit_sha is: ${{github.event.pull_request.merge_commit_sha}}"
8193
echo "github.event.pull_request is: ${{github.event.pull_request}}"
82-
83-
94+
8495
- name: Trigger Jenkins Pipeline
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 GITHUB_REPOSITORY="$GITHUB_REPOSITORY" -e svc_acc_org_secret="$svc_acc_org_secret" -e input_sha="$input_sha" -e input_pr_url="$input_pr_url" -e pipeline_name="$pipeline_name" \
100+
-e input_pr_num="$input_pr_num" -e PR_TITLE="$PR_TITLE" -e JENKINS_URL="$JENKINS_URL" -e GITHUB_PAT="$svc_acc_org_secret" "${{env.CONTAINER_NAME}}" \
101+
/bin/bash -c 'echo \"PR NUM: "$input_pr_num"\" && 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"'
102+
89103
- name: Stop and remove container
90104
if: always()
91105
run: |

0 commit comments

Comments
 (0)