|
46 | 46 | pip install ruff |
47 | 47 | ruff --output-format=github --exclude=src/onepassword/lib/ . |
48 | 48 | continue-on-error: true |
| 49 | + |
| 50 | + # Repo owner has commented /ok-to-test on a (fork-based) pull request |
| 51 | + integration-fork: |
| 52 | + runs-on: ubuntu-latest |
| 53 | + permissions: |
| 54 | + pull-requests: write |
| 55 | + checks: write |
| 56 | + if: | |
| 57 | + github.event_name == 'repository_dispatch' && |
| 58 | + github.event.client_payload.slash_command.args.named.sha != '' && |
| 59 | + contains( |
| 60 | + github.event.client_payload.pull_request.head.sha, |
| 61 | + github.event.client_payload.slash_command.args.named.sha |
| 62 | + ) |
| 63 | + steps: |
| 64 | + |
| 65 | + # Check out merge commit |
| 66 | + - name: Fork based /ok-to-test checkout |
| 67 | + uses: actions/checkout@v3 |
| 68 | + with: |
| 69 | + ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge' |
| 70 | + |
| 71 | + # <insert integration tests needing secrets> |
| 72 | + |
| 73 | + - run: | |
| 74 | + echo "Integration tests... success! ;-)" |
| 75 | +
|
| 76 | + # Update check run called "integration-fork" |
| 77 | + - uses: actions/github-script@v6 |
| 78 | + id: update-check-run |
| 79 | + if: ${{ always() }} |
| 80 | + env: |
| 81 | + number: ${{ github.event.client_payload.pull_request.number }} |
| 82 | + job: ${{ github.job }} |
| 83 | + # Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run |
| 84 | + conclusion: ${{ job.status }} |
| 85 | + with: |
| 86 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + script: | |
| 88 | + const { data: pull } = await github.rest.pulls.get({ |
| 89 | + ...context.repo, |
| 90 | + pull_number: process.env.number |
| 91 | + }); |
| 92 | + const ref = pull.head.sha; |
| 93 | +
|
| 94 | + const { data: checks } = await github.rest.checks.listForRef({ |
| 95 | + ...context.repo, |
| 96 | + ref |
| 97 | + }); |
| 98 | +
|
| 99 | + const check = checks.check_runs.filter(c => c.name === process.env.job); |
| 100 | +
|
| 101 | + const { data: result } = await github.rest.checks.update({ |
| 102 | + ...context.repo, |
| 103 | + check_run_id: check[0].id, |
| 104 | + status: 'completed', |
| 105 | + conclusion: process.env.conclusion |
| 106 | + }); |
| 107 | +
|
| 108 | + return result; |
0 commit comments