|
| 1 | +name: Resyntax Review Submission |
| 2 | + |
| 3 | +# The Resyntax integration is split into two workflows. See ./resyntax-analyze.yml for details about |
| 4 | +# why it works this way. |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_run: |
| 8 | + workflows: ["Resyntax Analysis"] |
| 9 | + types: |
| 10 | + - completed |
| 11 | + |
| 12 | +jobs: |
| 13 | + review: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: > |
| 16 | + ${{ github.event.workflow_run.event == 'pull_request' && |
| 17 | + github.event.workflow_run.conclusion == 'success' }} |
| 18 | + env: |
| 19 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + permissions: |
| 21 | + pull-requests: write |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + |
| 26 | + - name: Download Resyntax analysis |
| 27 | + # This uses a github script instead of the download-artifact action because |
| 28 | + # that action doesn't work for artifacts uploaded by other workflows. See |
| 29 | + # https://github.com/actions/download-artifact/issues/130 for more info. |
| 30 | + |
| 31 | + with: |
| 32 | + script: | |
| 33 | + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
| 34 | + owner: context.repo.owner, |
| 35 | + repo: context.repo.repo, |
| 36 | + run_id: ${{github.event.workflow_run.id}}, |
| 37 | + }); |
| 38 | + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { |
| 39 | + return artifact.name == "resyntax-review" |
| 40 | + })[0]; |
| 41 | + var download = await github.rest.actions.downloadArtifact({ |
| 42 | + owner: context.repo.owner, |
| 43 | + repo: context.repo.repo, |
| 44 | + artifact_id: matchArtifact.id, |
| 45 | + archive_format: 'zip', |
| 46 | + }); |
| 47 | + var fs = require('fs'); |
| 48 | + fs.writeFileSync('${{github.workspace}}/resyntax-review.zip', Buffer.from(download.data)); |
| 49 | + - run: unzip resyntax-review.zip |
| 50 | + - name: Create pull request review |
| 51 | + |
| 52 | + with: |
| 53 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + script: | |
| 55 | + var create_review_request = require('./resyntax-review.json'); |
| 56 | + await github.rest.pulls.createReview(create_review_request); |
0 commit comments