@evm-debuger/[email protected] #243
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 prod' | |
on: | |
release: | |
types: | |
- created | |
env: | |
NODE_VERSION: 18.16.0 | |
ENV: prod | |
AWS_EC2_METADATA_DISABLED: true | |
jobs: | |
frontend_deploy_prod: | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 15 | |
env: | |
BUCKET_NAME: www.rumblefish.dev.evm-debugger | |
PREFIX: evm-debugger | |
if: | | |
startsWith(github.ref, 'refs/tags/@evm-debuger/frontend') && | |
!contains(github.ref, '-alpha.') | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: 'Checkout' | |
uses: actions/[email protected] | |
- uses: actions/setup-node@master | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: 'https://npm.pkg.github.com' | |
scope: "@rumblefishdev" | |
- name: 'Cache NPM dependencies' | |
uses: pat-s/[email protected] | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.OS }}-npm-cache-${{ hashFiles('packages/*/package-lock.json') }} | |
restore-keys: | | |
${{ runner.OS }}-npm-cache- | |
- name: Install dependencies | |
run: | | |
npm i | |
node_modules/.bin/lerna bootstrap | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Check if @rumblefishdev/ui installed | |
run: | | |
if [[ ! -d packages/frontend/node_modules/@rumblefishdev/ui ]]; then | |
echo "Error: @rumblefishdev/ui not installed" | |
exit 1 | |
fi | |
- name: 'Build' | |
run: | | |
npm run types:build | |
npm run analyzer:build | |
npm run frontend:build:prod | |
env: | |
REACT_APP_STRAPI_AUTH_TOKEN: ${{ secrets.STRAPI_AUTH_TOKEN }} | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::428196107266:role/evm-debugger-frontend-deploy-prod | |
aws-region: us-east-1 | |
role-session-name: ${{ github.event.repository.name }}-${{ github.job }} | |
- name: 'Deploy' | |
run: | | |
aws s3 sync packages/frontend/build s3://${BUCKET_NAME}/${PREFIX} --delete --exact-timestamps | |
- name: Assume role on main AWS account | |
run: | | |
role_name=$(aws cloudformation describe-stacks --stack-name evm-transaction-trace-prod | jq -r '.Stacks[0].Parameters | map(select(.ParameterKey == "CloudfrontInvalidationRoleArn"))[0].ParameterValue') | |
output=$(aws sts assume-role --role-arn "$role_name" --role-session-name github-stage-frontend-Session) | |
echo "AWS_ACCESS_KEY_ID=$(echo $output | jq -r '.Credentials.AccessKeyId')" >> $GITHUB_ENV | |
echo "AWS_SECRET_ACCESS_KEY=$(echo $output | jq -r '.Credentials.SecretAccessKey')" >> $GITHUB_ENV | |
echo "AWS_SESSION_TOKEN=$(echo $output | jq -r '.Credentials.SessionToken')" >> $GITHUB_ENV | |
- name: Invalidate CloudFront | |
run: | | |
aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths "/${PREFIX}/*" | |
env: | |
DISTRIBUTION_ID: E3IK5XITYN78AJ | |
transaction_trace_deploy_prod: | |
runs-on: ubuntu-20.04 | |
if: | | |
startsWith(github.ref, 'refs/tags/@evm-debuger/transaction-trace') && | |
!contains(github.ref, '-alpha.') | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: 'Checkout' | |
uses: actions/[email protected] | |
- uses: actions/setup-node@master | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: 'Cache NPM dependencies' | |
uses: pat-s/[email protected] | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.OS }}-npm-cache-${{ hashFiles('packages/*/package-lock.json') }} | |
restore-keys: | | |
${{ runner.OS }}-npm-cache- | |
- name: Install dependencies | |
run: | | |
npm i | |
npm install jq.node -g | |
lerna bootstrap | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Build | |
run: | | |
npm run types:build | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::428196107266:role/evm-debugger-transaction-trace-deploy-prod | |
aws-region: us-east-1 | |
role-session-name: ${{ github.event.repository.name }}-${{ github.job }} | |
- name: Deploy stack | |
working-directory: ./packages/infra | |
run: | | |
make prod-deploy |