1
0
mirror of https://github.com/arduino/library-registry.git synced 2025-07-07 14:41:10 +03:00

Use curl to get PR diff

This approach allows the diff to be written directly to a file, rather than needing to sanitize the contents of the
output from the octokit/request-action before writing it to the file via the shell.
This commit is contained in:
per1234
2021-02-01 20:40:02 -08:00
parent da261b4a79
commit cb6c0a2bb5

View File

@ -48,20 +48,16 @@ jobs:
echo "::set-output name=filename::diff.txt" echo "::set-output name=filename::diff.txt"
- name: Get PR diff - name: Get PR diff
id: get-diff
uses: octokit/request-action@v2.x
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: run: |
mediaType: | # It's necessary to reference both pull_request.number and issue.number because only one of the two are defined depending on whether the workflow is triggered by PR or comment event.
format: diff curl \
route: GET /repos/{owner}/{repo}/pulls/{pull_number} --fail \
owner: ${{ github.repository_owner }} --output "${{ steps.configuration.outputs.path }}/${{ steps.configuration.outputs.filename }}" \
repo: ${{ github.event.repository.name }} --header "Authorization: token $GITHUB_TOKEN" \
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }} --header "Accept: application/vnd.github.v3.diff" \
https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls/${{ github.event.pull_request.number }}${{ github.event.issue.number }}
- name: Write diff to file
run: printf -- '%b' ${{ steps.get-diff.outputs.data }} > "${{ steps.configuration.outputs.path }}/${{ steps.configuration.outputs.filename }}"
- name: Upload diff file to workflow artifact - name: Upload diff file to workflow artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2