Skip to content

ci: release

ci: release #296

Workflow file for this run

name: CI
on:
push:
branches:
- main
- mainnet-prod
pull_request:
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
- name: Check Yarn version
run: yarn --version
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build
- name: Run unit tests
shell: bash
run: yarn test:unit
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Lint PR title
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'pull_request'
- name: Lint commit
uses: wagoid/commitlint-github-action@v5
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
- name: Check Yarn version
run: yarn --version
- name: Install dependencies
run: yarn install
- name: Lint workspaces
run: yarn lint
set-aws-region:
runs-on: ubuntu-latest
steps:
- name: Set AWS Region
id: set-aws-region
run: |
if [[ "${{ github.ref }}" == "refs/heads/mainnet-prod" ]]; then
echo "AWS_REGION=ap-northeast-1" >> $GITHUB_OUTPUT
fi
outputs:
AWS_REGION: ${{ steps.set-aws-region.outputs.AWS_REGION }}
build-and-push-poller-image:
if: github.ref == 'refs/heads/mainnet-prod'
env:
REGISTRY: 679752396206.dkr.ecr.${{ needs.set-aws-region.outputs.AWS_REGION }}.amazonaws.com
REPOSITORY: mark-poller
IMAGE_TAG: mark-poller-${{ github.sha }}
runs-on: ubuntu-latest
needs: [set-aws-region]
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ needs.set-aws-region.outputs.AWS_REGION }}
aws-access-key-id: ${{ secrets.DEPLOYER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOYER_AWS_SECRET_ACCESS_KEY }}
- name: Login to Private ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Build, tag, and push Docker image to Amazon ECR
id: build-image
run: |
docker build -f docker/poller/Dockerfile -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
terraform-deploy-mainnet-prod:
if: github.ref == 'refs/heads/mainnet-prod'
runs-on: ubuntu-latest
needs: [build-and-push-poller-image, set-aws-region]
env:
AWS_PROFILE: aws-deployer-connext
AWS_REGION: ${{ needs.set-aws-region.outputs.AWS_REGION }}
REGISTRY: 679752396206.dkr.ecr.${{ needs.set-aws-region.outputs.AWS_REGION }}.amazonaws.com
REPOSITORY: mark-poller
IMAGE_TAG: mark-poller-${{ github.sha }}
steps:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.5.7
- name: Setup Sops
uses: mdgreenwald/mozilla-sops-action@v1.2.0
with:
version: '3.7.2'
- name: Checkout repository
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: Fooji/create-aws-profile-action@v1
with:
profile: aws-deployer-connext
region: ${{ needs.set-aws-region.outputs.AWS_REGION }}
key: ${{ secrets.DEPLOYER_AWS_ACCESS_KEY_ID }}
secret: ${{ secrets.DEPLOYER_AWS_SECRET_ACCESS_KEY }}
- name: Decrypt Mainnet Secrets
id: decrypt
run: sops -d ops/env/mainnet/secrets.prod.json > ops/mainnet/prod/tfvars.json
- name: Terraform Init
working-directory: ./ops/mainnet/prod
run: terraform init
- name: Terraform Apply
working-directory: ./ops/mainnet/prod
run: |
terraform apply -var "image_uri=${REGISTRY}/${REPOSITORY}:${IMAGE_TAG}" -var-file=tfvars.json -auto-approve
env:
TF_LOG: INFO