From 0fbf65f5cd894c537ab78acb29e14c5fa2c5fb47 Mon Sep 17 00:00:00 2001 From: Moritz Johner Date: Tue, 25 Jan 2022 08:12:35 +0100 Subject: [PATCH] fix(e2e): create check dynamically Signed-off-by: Moritz Johner --- .github/workflows/e2e-managed.yml | 47 +++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-managed.yml b/.github/workflows/e2e-managed.yml index adf221f6f..81dfb2dcb 100644 --- a/.github/workflows/e2e-managed.yml +++ b/.github/workflows/e2e-managed.yml @@ -1,6 +1,5 @@ # Run secret-dependent e2e tests only after /ok-to-test-managed approval on: - pull_request: repository_dispatch: types: [ok-to-test-managed-command] @@ -49,6 +48,48 @@ jobs: steps: + # create new status check for this specific provider + - uses: actions/github-script@v1 + if: ${{ always() }} + env: + number: ${{ github.event.client_payload.pull_request.number }} + provider: ${{ github.event.client_payload.slash_command.args.named.provider }} + job: ${{ github.job }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: pull } = await github.pulls.get({ + ...context.repo, + pull_number: process.env.number + }); + const ref = pull.head.sha; + console.log("\n\nPR sha: " + ref) + const { data: checks } = await github.checks.listForRef({ + ...context.repo, + ref + }); + const job_name = process.env.job + "-" + process.env.provider + console.log("\n\nPR CHECKS: " + checks) + const check = checks.check_runs.filter(c => c.name === job_name); + console.log("\n\nPR Filtered CHECK: " + check) + console.log(check) + if(check){ + const { data: result } = await github.checks.update({ + ...context.repo, + check_run_id: check[0].id, + status: 'in_progress', + }); + return result; + } + const { data: result } = await github.checks.create({ + ...context.repo, + check_run_id: check[0].id, + name: job_name, + status: 'in_progress', + }); + return result; + + # Check out merge commit - name: Fork based /ok-to-test-managed checkout uses: actions/checkout@v2 @@ -164,6 +205,7 @@ jobs: if: ${{ always() }} env: number: ${{ github.event.client_payload.pull_request.number }} + provider: ${{ github.event.client_payload.slash_command.args.named.provider }} job: ${{ github.job }} # Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run conclusion: ${{ job.status }} @@ -180,8 +222,9 @@ jobs: ...context.repo, ref }); + const job_name = process.env.job + "-" + process.env.provider console.log("\n\nPR CHECKS: " + checks) - const check = checks.check_runs.filter(c => c.name === process.env.job); + const check = checks.check_runs.filter(c => c.name === job_name); console.log("\n\nPR Filtered CHECK: " + check) console.log(check) const { data: result } = await github.checks.update({