forked from google/tour-of-wgsl
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (72 loc) · 2.38 KB
/
deploy-pr.yml
File metadata and controls
86 lines (72 loc) · 2.38 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Deploy PR
# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ['Build PR']
types:
- completed
permissions:
contents: write
pull-requests: write
# Default to bash
defaults:
run:
shell: bash
jobs:
deploy-pr:
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
env:
id: ${{ github.event.workflow_run.id }}
HUGO_VERSION: 0.111.3
steps:
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Extracting PR info
run: |
echo "PR=$(cat pull-request.info)" >> $GITHUB_ENV
rm pull-request.info
- run: |
git init
git config user.name github-actions
git config user.email github-actions@github.com
git commit --allow-empty -m "deploy needs a HEAD"
- name: Deploy preview GitHub Pages
uses: JamesIves/github-pages-deploy-action@4.1.3
with:
branch: gh-pages
folder: .
target-folder: pr-preview/pr-${{ env.PR }}
commit-message: Deploy preview for PR ${{ env.PR }}
clean-exclude: pr-preview/
- name: Add PR comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
number: ${{ env.PR }}
message: '[Preview of pull-request can be viewed here](${{ steps.pages.outputs.base_url }}/pr-preview/pr-${{ env.PR }}/)'