Skip to content

chore(workspace): configure .mend (VIV-000) #958

chore(workspace): configure .mend (VIV-000)

chore(workspace): configure .mend (VIV-000) #958

name: Build & Deploy Showcase (Dev)
on:
pull_request:
types: [closed]
branches: [master]
jobs:
build-deploy-demo-dev:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_B }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_SECRET_B }}
AWS_DEFAULT_REGION: eu-west-2
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup NodeJS 14
uses: actions/setup-node@v2
with:
node-version: 14
- run: printf "registry=https://npm.pkg.github.com/Vonage\n_authToken=\${GITHUB_TOKEN}\n//npm.pkg.github.com/:_authToken=\${GITHUB_TOKEN}\nalways-auth=true" > .npmrc
- name: Install yarn
run: npm install -g yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Cache yarn dependencies
uses: actions/cache@v2
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: vivid-cache-yarn-${{ hashFiles('**/package.json') }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --network-timeout 100000
- name: Build storybook
run: yarn storybook:build
- name: Create deploy timestamp/version
run: echo "STORYBOOK_DEPLOY_TIMESTAMP=$(jq -r '.timestamp' ./.storybook/static/build-details.json)" >> $GITHUB_ENV
- name: Deploy showcase versioned as ${{ env.STORYBOOK_DEPLOY_TIMESTAMP }}
run: aws s3 sync ./.out/ s3://${{ secrets.AWS_S3_BUCKET_B }}/${{ env.STORYBOOK_DEPLOY_TIMESTAMP }}
- name: Update CloudFront distribution root object ${{ env.STORYBOOK_DEPLOY_TIMESTAMP }}
run: aws cloudfront update-distribution --id ${{ secrets.AWS_CF_DISTRIBUTION_ID_B }} --default-root-object ${{ env.STORYBOOK_DEPLOY_TIMESTAMP }}/index.html
- name: Invalidate CloudFront distribution root object's cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID_B }} --paths "/"