-
Notifications
You must be signed in to change notification settings - Fork 2.3k
53 lines (49 loc) · 1.88 KB
/
deploy-gh-pages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# inspired by https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
name: Deploy SwaggerEditor@next to GitHub Pages
on:
workflow_run:
workflows: ["SwaggerEditor@next build", "SwaggerEditor@next nightly build"]
types:
- completed
branches: [next]
jobs:
deploy:
if: >
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.conclusion == 'success'
name: Deploy SwaggerEditor@next to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: next
- 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