Skip to content

Commit

Permalink
Trigger preview deploy on certain PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kas-tle authored Apr 14, 2024
1 parent a24f684 commit 021ac5e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
14 changes: 14 additions & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
script: |
github.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'preview.yml',
ref: 'master',
inputs: {
runId: '${{ github.run_id }}'
}
});

0 comments on commit 021ac5e

Please sign in to comment.