-
Notifications
You must be signed in to change notification settings - Fork 910
100 lines (86 loc) · 3.51 KB
/
preview-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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Preview GitHub Pages
on:
pull_request:
types: [synchronize, opened, reopened]
env:
# Among other things, opts out of Turborepo telemetry
# See https://consoledonottrack.com/
DO_NOT_TRACK: '1'
# Some tasks slow down considerably on GitHub Actions runners when concurrency is high
TURBO_CONCURRENCY: 1
# Enables Turborepo Remote Caching.
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
jobs:
compile-gh-pages-legacy:
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: maintenance/v1.x
- name: Install Dependencies
uses: ./.github/workflows/actions/install-dependencies
- name: Compile and Upload Artifacts
uses: ./.github/workflows/actions/compile-gh-pages
compile-gh-pages:
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Dependencies
uses: ./.github/workflows/actions/install-dependencies
- name: Compile and Upload Artifacts
uses: ./.github/workflows/actions/compile-gh-pages
with:
pr-number: ${{ github.event.pull_request.number }}
repository: solana-web3.js-pr-preview
preview:
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
needs: [compile-gh-pages, compile-gh-pages-legacy]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Dependencies
uses: ./.github/workflows/actions/install-dependencies
- name: Download Deploy Directory from Artifact Cache
uses: actions/download-artifact@v4
with:
path: .ghpages-deploy
pattern: ghpages-deploy-artifacts*
merge-multiple: true
- name: Deploy to Preview Github Pages
uses: peaceiris/actions-gh-pages@v4
with:
destination_dir: ${{ format('{0}/', github.event.pull_request.number) }}
external_repository: solana-labs/solana-web3.js-pr-preview
personal_token: ${{ secrets.PR_PREVIEW_REPO_CONTENTS_TOKEN }}
publish_dir: .ghpages-deploy
- name: Find Existing Preview Link Comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: <!-- GH_PAGES_PREVIEW_BOT_COMMENT -->
- name: Create Preview Link Comment
uses: actions/github-script@v7
if: steps.find-comment.outputs.comment-id == ''
with:
script: >
const prNumber = context.issue.number;
github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: [
'<!-- GH_PAGES_PREVIEW_BOT_COMMENT -->',
'A preview of the GitHub Pages site based on this PR is now available here:',
'',
`<a href="https://solana-labs.github.io/solana-web3.js-pr-preview/${prNumber}/" rel="noopener noreferrer" target="_blank">solana-labs.github.io/solana-web3.js-pr-preview/${prNumber}/</a>`,
].join('\n'),
});