Skip to content

Deployment

Deployment #426

Workflow file for this run

name: Deployment
on:
workflow_dispatch: {}
push:
branches:
- main
permissions:
id-token: write
contents: read
packages: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/install
- uses: ./.github/actions/verify
- name: Build Docker Image
run: docker build --tag ghcr.io/sourceallies/hacker-rank-queue:${{ github.sha }} .
- name: Push Docker Image
run: docker push ghcr.io/sourceallies/hacker-rank-queue:${{ github.sha }}
deploy-dev:
name: Deploy Dev
needs: build
runs-on: ubuntu-latest
concurrency: dev
environment: Development
env:
ENV_NAME: dev
IMAGE: ghcr.io/sourceallies/hacker-rank-queue:${{ github.sha }}
steps:
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Checkout Repo
uses: actions/checkout@v4
with:
lfs: true
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- uses: ./.github/actions/install
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.DEV_ROLE_ARN }}
- name: CDK Bootstrap
working-directory: ./.aws
run: pnpm cdk bootstrap
shell: bash
- name: Deploy
working-directory: ./.aws
run: pnpm infra:up
shell: bash
- name: Notify Slack Success
uses: slackapi/slack-github-action@v1.26.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'coding-exercise-queue'
slack-message: ':white_check_mark: Deployment to *dev* succeeded'
- name: Notify Slack Failure
uses: slackapi/slack-github-action@v1.26.0
if: ${{ failure() }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'coding-exercise-queue'
slack-message: ':x: Deployment to *dev* failed'
deploy-prod:
name: Deploy Prod
needs: deploy-dev
runs-on: ubuntu-latest
concurrency: prod
environment: Production
env:
ENV_NAME: prod
IMAGE: ghcr.io/sourceallies/hacker-rank-queue:${{ github.sha }}
steps:
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Checkout Repo
uses: actions/checkout@v4
with:
lfs: true
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- uses: ./.github/actions/install
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.PROD_ROLE_ARN }}
- name: CDK Bootstrap
working-directory: ./.aws
run: pnpm cdk bootstrap
shell: bash
- name: Deploy
working-directory: ./.aws
run: pnpm infra:up
shell: bash
- name: Notify Slack Success
uses: slackapi/slack-github-action@v1.26.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'coding-exercise-queue'
slack-message: ':white_check_mark: Deployment to *prod* succeeded'
- name: Notify Slack Failure
uses: slackapi/slack-github-action@v1.26.0
if: ${{ failure() }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'coding-exercise-queue'
slack-message: ':x: Deployment to *prod* failed'