Skip to content

Deployments

Deployments #59

Workflow file for this run

name: Deployments
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy'
type: environment
required: true
jobs:
deploy:
environment: ${{ inputs.environment }}
name: Deploy Snap and UI
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- 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: eu-central-1
- name: Use Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 20.x
registry-url: 'https://registry.npmjs.org'
- name: Get Yarn cache directory
run: echo "::set-output name=YARN_CACHE_DIR::$(yarn cache dir)"
id: yarn-cache-dir
- name: Get Yarn version
run: echo "::set-output name=YARN_VERSION::$(yarn --version)"
id: yarn-version
- name: Cache yarn dependencies
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}
- run: yarn install --no-immutable
- run: yarn setup
- run: yarn clean
- name: Staging Deployment
run: |
VERSION=$(node -p "require('./packages/starknet-snap/package.json').version")
REACT_APP_SNAP_VERSION=${VERSION}-staging yarn workspace wallet-ui build
npm --prefix ./packages/starknet-snap version --new-version ${VERSION}-staging --no-git-tag-version
SNAP_ENV=staging yarn workspace @consensys/starknet-snap build
npm publish ./packages/starknet-snap --tag staging --access public 2>&1 > /dev/null || :
aws s3 sync ./packages/wallet-ui/build s3://staging.snaps.consensys.io/starknet
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: inputs.environment == 'staging'
- name: Production Deployment
run: |
VERSION=$(node -p "require('./packages/starknet-snap/package.json').version")
REACT_APP_SNAP_VERSION=${VERSION} REACT_APP_DEBUG_LEVEL=off yarn workspace wallet-ui build
npm --prefix ./packages/starknet-snap version --new-version ${VERSION} --no-git-tag-version --allow-same-version
SNAP_ENV=prod yarn workspace @consensys/starknet-snap build
npm publish ./packages/starknet-snap --tag latest --access public 2>&1 > /dev/null || :
aws s3 sync ./packages/wallet-ui/build s3://snaps.consensys.io/starknet
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: inputs.environment == 'production'
- name: invalid aws cloudfront cache
env:
AWS_CLOUDFRONT_DISTRIBUTIONS_ID: ${{ vars.AWS_CLOUDFRONT_DISTRIBUTIONS_ID }}
run: |
echo "Distribution ID : $AWS_CLOUDFRONT_DISTRIBUTIONS_ID"
for process in $(echo $AWS_CLOUDFRONT_DISTRIBUTIONS_ID | sed "s/,/ /g")
do
echo "Processing Distribution ID : $process"
id="$(aws cloudfront create-invalidation --distribution-id $process --paths "/starknet/*" | grep Id | awk -F'"' '{ print $4}')"
echo "Waiting for invalidation $id"
aws cloudfront wait invalidation-completed --id $id --distribution-id $process
echo "Invalidation $id completed"
done