This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
72 lines (70 loc) · 2.49 KB
/
gatsby.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
name: 'Gatsby build only on PR'
on:
pull_request:
types: [opened, edited, synchronize]
jobs:
build:
name: Build Gatsby Site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Npm Setup
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Npm Install
run: |
npm i
- name: Lint
run: npm run lint
- name: PR Branch Name
uses: mdecoleman/[email protected]
id: branchname
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: GitHub Environment Variables Action
uses: FranzDiebold/[email protected]
- name: Get PR commit trigger SHA
uses: bhowell2/[email protected]
id: prsha
with:
value: ${{ github.event.pull_request.head.sha }}
length_from_start: 6
- name: Get short SHA6
id: slug
env:
PRSHA: ${{ steps.prsha.outputs.substring }}
run: echo "::set-output name=sha6::$(echo ${PRSHA} | cut -c1-6)"
- name: Get PR commit trigger SHA
uses: bhowell2/[email protected]
id: prsha7
with:
value: ${{ github.event.pull_request.head.sha }}
length_from_start: 7
- name: Get short SHA7
id: slug7
env:
PRSHA: ${{ steps.prsha7.outputs.substring }}
run: echo "::set-output name=sha7::$(echo ${PRSHA} | cut -c1-7)"
- name: Modify gatsby prefix in gatsby-config.js
env:
SHA: ${{ steps.slug.outputs.sha6 }}
BRANCH: ${{ steps.branchname.outputs.branch }}
SLUG: ${{ env.GITHUB_REPOSITORY_NAME }}
run: |
sed -i "s@pathPrefix: ''@pathPrefix: '/${SLUG}/review-apps/${BRANCH}/${SHA}'@g" gatsby-config.js
- name: Build and deploy to gh-pages
uses: sauloxd/[email protected]
with:
build-cmd: 'npx gatsby build --prefix-paths'
branch: 'gh-pages'
dist: 'public'
slug: 'review-apps'
- name: Comment URL on PR
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ github.event.pull_request.head.sha }}
with:
msg: 'https://${{env.GITHUB_REPOSITORY_OWNER_SLUG}}.github.io/${{env.GITHUB_REPOSITORY_NAME}}/review-apps/${{steps.branchname.outputs.branch}}/${{steps.slug.outputs.sha6}}?version=${{steps.slug7.outputs.sha7}}'
check_for_duplicate_msg: false