.github: Write PR data to a file first in trigger-gitlab

Using echo breaks if any PR body contains a `'` character.
This commit is contained in:
Sanne Raymaekers 2021-10-06 13:03:05 +02:00
parent 11dea50050
commit 79f842d4e7

View file

@ -36,7 +36,13 @@ jobs:
- name: Checkout branch
run: |
PR=$(echo '${{ steps.fetch_pulls.outputs.data }}' | jq -rc '.[] | select(.head.sha | contains("${{ github.event.workflow_run.head_sha }}")) | select(.state | contains("open"))' | jq -r .number)
PR_DATA=$(mktemp)
# use uuid as a file terminator to avoid conflicts with data content
cat > "$PR_DATA" <<a21b3e7f-d5eb-44a3-8be0-c2412851d2e6
${{ steps.fetch_pulls.outputs.data }}
a21b3e7f-d5eb-44a3-8be0-c2412851d2e6
PR=$(jq -rc '.[] | select(.head.sha | contains("${{ github.event.workflow_run.head_sha }}")) | select(.state | contains("open"))' "$PR_DATA" | jq -r .number)
if [ ! -z "$PR" ]; then
git checkout -b PR-$PR
else