diff options
author | Bjarne Koll <[email protected]> | 2024-05-28 14:02:20 +0200 |
---|---|---|
committer | Bjarne Koll <[email protected]> | 2024-05-28 14:23:35 +0200 |
commit | 3e933fe49d526b6d5e671cb6314ade7e95d69d86 (patch) | |
tree | 9bf6e0966559bb94a152d5d36042049832fc45c3 | |
parent | 483368e480eb2ec060d8e68b30e14ec96aba6c4e (diff) | |
download | Paper-3e933fe49d526b6d5e671cb6314ade7e95d69d86.tar.gz Paper-3e933fe49d526b6d5e671cb6314ade7e95d69d86.zip |
[ci skip] Clean up paperclip build-pr workflowver/1.19.4
Gracefully handle paperclip uploads to pull requests in case of build
workflow issues.
-rw-r--r-- | .github/workflows/build.yml | 15 | ||||
-rw-r--r-- | .github/workflows/pr_comment.yml | 24 |
2 files changed, 26 insertions, 13 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 20ca9be6b2..6a16f18669 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,15 +34,20 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Configure Build - uses: actions/github-script@v6 + uses: actions/github-script@v7 id: determine + env: + REF_NAME: "${{ github.ref_name }}" + REF_TYPE: "${{ github.ref_type }}" + EVENT: "${{ toJSON(github.event) }}" + EVENT_TYPE: "${{ github.event_name }}" with: script: | const {owner, repo} = context.repo; - const event_name = "${{ github.event_name }}"; - const event = ${{ toJSON(github.event) }}; - const ref_type = "${{ github.ref_type }}"; - const ref_name = "${{ github.ref_name }}"; + const event_name = `${process.env.EVENT_TYPE}`; + const event = JSON.parse(`${process.env.EVENT}`); + const ref_type = `${process.env.REF_TYPE}`; + const ref_name = `${process.env.REF_NAME}`; const result = { action: "build" }; diff --git a/.github/workflows/pr_comment.yml b/.github/workflows/pr_comment.yml index 2e3c6d5a55..60bed3fd38 100644 --- a/.github/workflows/pr_comment.yml +++ b/.github/workflows/pr_comment.yml @@ -17,7 +17,15 @@ jobs: if: github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest steps: - - uses: actions/github-script@v6 + - uses: actions/github-script@v7 + env: + BRANCH_NAME: "${{ github.event.workflow_run.head_branch }}" + PR_OWNER: "${{ github.event.workflow_run.head_repository.owner.login }}" + PR_SHA: "${{ github.event.workflow_run.head_sha }}" + RUN_ID: "${{ github.event.workflow_run.id }}" + REPO_ID: "${{ github.event.repository.id }}" + EVENT_TYPE: "${{ github.event.workflow_run.event}}" + PULL_REQUESTS: "${{ toJSON(github.event.workflow_run.pull_requests) }}" with: # This snippet is public-domain, taken from # https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml @@ -37,17 +45,17 @@ jobs: } const { owner, repo } = context.repo; - const run_id = ${{ github.event.workflow_run.id }}; - const repo_id = ${{ github.event.repository.id }}; + const run_id = `${process.env.RUN_ID}`; + const repo_id = `${process.env.REPO_ID}`; let pulls = []; - const event_type = "${{ github.event.workflow_run.event}}"; + const event_type = `${process.env.EVENT_TYPE}`; if (event_type === "push") { // if push, it's from the same repo which means `pull_requests` is populated - pulls = ${{ toJSON(github.event.workflow_run.pull_requests) }}; + pulls = JSON.parse(`${process.env.PULL_REQUESTS}`); } else { - const pr_branch = "${{ github.event.workflow_run.head_branch }}"; - const pr_sha = "${{ github.event.workflow_run.head_sha }}"; - const pr_owner = "${{ github.event.workflow_run.head_repository.owner.login }}"; + const pr_branch = `${process.env.BRANCH_NAME}`; + const pr_sha = `${process.env.PR_SHA}`; + const pr_owner = `${process.env.PR_OWNER}`; const { data } = await github.rest.pulls.list({ owner, repo, head: `${pr_owner}:${pr_branch}`, state: "open" }); core.debug(JSON.stringify(data, null, 2)); pulls = data.filter((pr) => pr.head.sha === pr_sha && pr.labels.find((l) => l.name === "build-pr-jar")); |