From 021ac5ef79ab05aad7dbc1311cdb4992c62f3e72 Mon Sep 17 00:00:00 2001 From: Kas-tle <26531652+Kas-tle@users.noreply.github.com> Date: Sun, 14 Apr 2024 11:00:43 -0700 Subject: [PATCH] Trigger preview deploy on certain PRs --- .github/workflows/preview.yml | 42 +++++++++++++++++++++++++++++++ .github/workflows/pullrequest.yml | 14 +++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 00000000000..ec46f32a5a6 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,42 @@ +name: Upload Preview + +on: + workflow_dispatch: + inputs: + runId: + required: true + description: 'ID of the Build Pull Request Run' + +jobs: + upload: + runs-on: ubuntu-latest + steps: + - name: 'Download all artifacts' + uses: actions/github-script@v3.1.0 + with: + script: | + const run_id = ${{ github.event.inputs.runId }}; + const artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: run_id, + }); + + // Loop through all artifacts and download them + for (const artifact of artifacts.data.artifacts) { + const download = await github.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact.id, + archive_format: 'zip', + }); + const fs = require('fs'); + // Write each artifact to a separate file named after the artifact + fs.writeFileSync(`${{github.workspace}}/${artifact.name}.zip`, Buffer.from(download.data)); + } + - name: 'Unzip artifacts' + run: | + mkdir -p ${{github.workspace}}/artifacts + for zip in ${{github.workspace}}/*.zip; do + unzip -d ${{github.workspace}}/artifacts "$zip" + done \ No newline at end of file diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 93be4711edc..ad5fc1b0ea2 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -102,3 +102,17 @@ jobs: name: Geyser ViaProxy path: geyser/bootstrap/viaproxy/build/libs/Geyser-ViaProxy.jar if-no-files-found: error + - name: Trigger Preview Deployment + if: 'contains(github.event.pull_request.labels.*.name, "PR: Needs Testing")' + uses: actions/github-script@v3.1.0 + with: + script: | + github.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'preview.yml', + ref: 'master', + inputs: { + runId: '${{ github.run_id }}' + } + }); \ No newline at end of file