Resyntax Review Submission #117
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Resyntax Review Submission | |
# The Resyntax integration is split into two workflows. See ./resyntax-analyze.yml for details about | |
# why it works this way. | |
on: | |
workflow_run: | |
workflows: ["Resyntax Analysis"] | |
types: | |
- completed | |
jobs: | |
review: | |
runs-on: ubuntu-latest | |
if: > | |
${{ github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion == 'success' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
- name: Download Resyntax analysis | |
# This uses a github script instead of the download-artifact action because | |
# that action doesn't work for artifacts uploaded by other workflows. See | |
# https://github.com/actions/download-artifact/issues/130 for more info. | |
uses: actions/[email protected] | |
with: | |
script: | | |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{github.event.workflow_run.id}}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "resyntax-review" | |
})[0]; | |
var download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/resyntax-review.zip', Buffer.from(download.data)); | |
- run: unzip resyntax-review.zip | |
- name: Create pull request review | |
uses: actions/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
var create_review_request = require('./resyntax-review.json'); | |
await github.rest.pulls.createReview(create_review_request); |