This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
Add version #88
Workflow file for this run
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
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 |