Validate PR -- #200
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: Validate PR -- | |
on: | |
schedule: | |
- cron: '*/5 * * * *' | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
validate_job_name: validation-tests # must match env of same name in pr-validate-fork | |
jobs: | |
e2eV2: | |
if: github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) | |
uses: ./.github/workflows/e2ev2-matrix.yaml | |
secrets: inherit | |
status: | |
permissions: | |
checks: write | |
pull-requests: read | |
needs: [e2eV2] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Update status | |
uses: actions/github-script@v6 | |
id: update-check-run | |
env: | |
number: ${{ github.event.number }} | |
conclusion: ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')) && 'failure' || 'success' }} | |
server_url: ${{ github.server_url }} | |
repo: ${{ github.repository }} | |
run_id: ${{ github.run_id }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
var ref; | |
const url = `${process.env.server_url}/${process.env.repo}/actions/runs/${process.env.run_id}` | |
if (context.eventName == 'pull_request') { | |
const { data: pull } = await github.rest.pulls.get({ | |
...context.repo, | |
pull_number: process.env.number | |
}); | |
console.log('retrieved pull request') | |
ref = pull.head.sha; | |
} | |
if (context.eventName == 'schedule') { | |
ref = context.sha; | |
} | |
if (ref != null) { | |
const { data: result } = await github.rest.checks.create({ | |
...context.repo, | |
name: process.env.validate_job_name, | |
head_sha: ref, | |
status: 'completed', | |
conclusion: process.env.conclusion, | |
details_url: url, | |
}); | |
console.log('created check') | |
return result; | |
} | |