Skip to content

Update CI/CD

Update CI/CD #17

Workflow file for this run

# Copyright (C) 2024, Nuklai. All rights reserved.
# See the file LICENSE for licensing terms.
name: VM Release deployment
on:
push:
branches:
- dev
- prod
workflow_dispatch:
permissions:
id-token: write
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
AWS_REGION: ${{ vars.AWS_REGION }}
ENVIRONMENT: ${{ vars.ENVIRONMENT }}
AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
PRODUCT: nuklaivm
APPLICATION: nodes
TARBALL_NAME: nuklaivm-${{ github.sha }}.tar.gz
jobs:
build_and_deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/prod' && 'prod' || github.ref == 'refs/heads/dev' && 'dev' || 'dev' }}
steps:
- name: Checkout
uses: actions/checkout@v4
# - uses: ./.github/actions/vm-release
# with:
# vm-name: nuklaivm
# github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build tar ball
run: |
EXCLUDES=$(cat .gitignore .dockerignore 2>/dev/null | grep -v '^#' | sed '/^$/d' | sed 's/^/--exclude=/' | tr '\n' ' ')
EXCLUDES+=" --exclude='./web_wallet'"
touch ${{ env.TARBALL_NAME }}
eval "tar -czf ${{ env.TARBALL_NAME }} --exclude=${{ env.TARBALL_NAME }} $EXCLUDES -C . ."
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/${{ env.PRODUCT }}-${{ env.APPLICATION }}-deployer-${{ env.AWS_REGION }}-${{ env.ENVIRONMENT }}
aws-region: ${{ env.AWS_REGION }}
- name: Push to S3
run: |
aws s3 sync ${{ env.TARBALL_NAME }} s3://${{ env.AWS_S3_BUCKET }} --follow-symlinks --delete --no-progress