Skip to content

ci: updates upload and download artifact steps in build and deploy steps #230

ci: updates upload and download artifact steps in build and deploy steps

ci: updates upload and download artifact steps in build and deploy steps #230

Workflow file for this run

name: CD
on:
push:
branches:
- master
env:
NODE_ENV: production
NODE_VERSION: 15.x
jobs:
semantic-release:
name: "Semantic Release 🗂"
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-20.04
env:
CI: true
GIT_AUTHOR_NAME: ${{ github.event.pusher.name }}
GIT_AUTHOR_EMAIL: ${{ github.event.pusher.email }}
GIT_COMMITTER_NAME: St. Jude Cloud
GIT_COMMITTER_EMAIL: support@stjude.cloud
HUSKY: 0
NODE_ENV: development
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/setup-python@v4
with:
python-version: "pypy2.7"
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-release-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-release-
- name: Install Node Dependencies
run: npm install
- name: Build and Publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release
git describe --tags --abbrev=0 > ./VERSION
- name: Upload Version File
uses: actions/upload-artifact@v4
with:
name: version-file
path: ./VERSION
if-no-files-found: error
retention-days: 3
- name: Print Version Number
run: cat ./VERSION
build:
name: "Gatsby Build 🧰"
runs-on: ubuntu-20.04
needs: [semantic-release]
env:
CI: true
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/setup-python@v4
with:
python-version: "pypy2.7"
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
- name: Install Node Dependencies
run: npm install
env:
NODE_ENV: development
- name: Cache Gatsby folder
uses: actions/cache@v2
with:
path: .cache
key: ${{ runner.os }}-cache-gatsby
restore-keys: |
${{ runner.os }}-cache-gatsby
- name: Cache Public folder
uses: actions/cache@v2
with:
path: public/
key: ${{ runner.os }}-public-gatsby
restore-keys: |
${{ runner.os }}-public-gatsby
- uses: actions/download-artifact@v4
with:
name: version-file
path: .
- name: Run Build
run: |
GATSBY_DOCS_VERSION=$(cat ./VERSION) GATSBY_DOCS_HASH=$(git rev-parse --short "$GITHUB_SHA") npm run build
env:
GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES: true
NODE_ENV: production
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ secrets.GATSBY_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_SEARCH_KEY: ${{ secrets.GATSBY_ALGOLIA_SEARCH_KEY }}
INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Built Site
uses: actions/upload-artifact@v4
with:
name: gatsby-public-folder
path: public/
if-no-files-found: error
retention-days: 3
deploy:
name: "Deploy to Netlify 🚀"
if: github.ref == 'refs/heads/master'
needs: [build, semantic-release]
runs-on: ubuntu-latest
env:
CI: true
steps:
- uses: actions/download-artifact@v4
with:
name: gatsby-public-folder
path: public/
- name: Display structure of downloaded files
run: ls -R
working-directory: public/
- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v1.1
with:
publish-dir: "./public"
production-branch: master
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 10