Skip to content

CI/CD for nautible front app #50

CI/CD for nautible front app

CI/CD for nautible front app #50

Workflow file for this run

name: CI/CD for nautible front app
on:
push:
branches: [ "develop","feature/*","hotfix/*" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
environment: develop # for azure oidc
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: setup node
uses: actions/setup-node@v1
with:
node-version: '18.x'
- name: Cache node modules
uses: actions/cache@v2
with:
path: ./app/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# AWS
- name: setup env file for aws
run: |
cd $GITHUB_WORKSPACE/app
sed -e "s/\$domain/${{ secrets.AWS_CLOUDFRONT_DOMAIN }}/" .env.auth-sample > .env
- name: Build for aws
env:
CI: false
run: |
cd $GITHUB_WORKSPACE/app
yarn
yarn build
- name: Test for aws
env:
CI: false
run: |
cd $GITHUB_WORKSPACE/app
yarn test
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/nautible-dev-githubactions-static-web-deploy-role
aws-region: ap-northeast-1
- name: deploy to aws s3
run: |
cd $GITHUB_WORKSPACE/app
aws s3 sync ./build s3://${{ secrets.AWS_S3_STATIC_WEB_BUCKET }} --exclude "*.git/*" --delete
# Azure
- name: setup env file for azure
run: |
cd $GITHUB_WORKSPACE/app
sed -e "s/\$domain/${{ secrets.AZURE_FRONTDOOR_DOMAIN }}/" .env.auth-sample > .env
- name: Build for azure
env:
CI: false
run: |
cd $GITHUB_WORKSPACE/app
yarn
yarn build
- name: Azure Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: deploy to azure storage account
run: |
cd $GITHUB_WORKSPACE/app
az storage blob upload-batch --account-name nautibledevstaticweb -d '$web' -s ./build --overwrite=True