Deploy ApiDOM Playground #3104
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
# inspired by https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | |
name: Deploy ApiDOM Playground | |
on: | |
workflow_run: | |
workflows: ["ApiDOM Monorepo Build"] | |
types: | |
- completed | |
branches: | |
- main | |
jobs: | |
deploy: | |
if: > | |
${{ github.event.workflow_run.event == 'push' && | |
github.ref == 'refs/heads/main' && | |
github.event.workflow_run.conclusion == 'success' }} | |
name: Deploy ApiDOM Playground | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 'Download build artifact' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
const matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "build" | |
})[0]; | |
const download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
const fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data)); | |
- run: | | |
mkdir deploy-dir | |
unzip build.zip -d deploy-dir | |
- name: Deploy 🚀 | |
uses: JamesIves/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: gh-pages # The branch the action should deploy to. | |
folder: deploy-dir # The folder the action should deploy. | |
clean: true # Automatically remove deleted files from the deploy branch |