Adjust readme language #123
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: Deploy to staging | |
concurrency: | |
group: deploy-stage-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- "**" # always deploy for branches | |
tags-ignore: | |
- "**" # never deploy for tags | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v2 | |
- name: Load .env file | |
uses: xom9ikk/dotenv@v2 | |
- name: Use Node.js 14.x | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 14 | |
- name: Use npm v7 | |
run: npm install --global npm@7 | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS | |
key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: npm install | |
run: npm ci --production | |
- name: Build the project | |
run: npm run build | |
- name: Upload build | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: ./build | |
if-no-files-found: error | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Download build | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: ./build | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_S3_STAGING_REGION }} | |
- name: Invalidate CloudFront (clear cache) | |
uses: chetan/invalidate-cloudfront-action@v2 | |
env: | |
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION }} | |
PATHS: ${{ format('/{0}/*', steps.delivery-path-prefix.outputs.result) }} | |
- name: Prepare the Delivery path prefix | |
uses: actions/github-script@v3 | |
id: delivery-path-prefix | |
with: | |
result-encoding: string | |
script: | | |
// Print out production slug: | |
const slug = `${{ env.REACT_APP_SLUG }}`; | |
console.log(`production slug will be -> ${slug.trim()}`); | |
// import path module | |
const path = require('path'); | |
// get reference to this commit | |
const ref = context.ref; | |
// get repo that triggered this push | |
const { repo } = context.repo; | |
// pull branch name off the ref | |
const parts = ref.split('/'); | |
const branch = parts[parts.length - 1]; | |
// build path used for this deploy | |
const basePath = path.join(repo, branch); | |
// return the prepared path as the output | |
return basePath; | |
- name: Upload the prepared files | |
uses: datadesk/delivery-deploy-action@master | |
with: | |
bucket: ${{ secrets.AWS_S3_STAGING_BUCKET }} | |
base-path: ${{ steps.delivery-path-prefix.outputs.result }} | |
dir: build | |
should-cache: true | |
use-accelerate-endpoint: false | |
public: true |