Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CICD pipeline for automated deployment #234

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI/CD ⚙️

on:
push:
release:
types:
- published
workflow_dispatch:
inputs:
environment:
description: 'Environment to run deploy'
type: environment
required: true
force:
description: 'Deploy even if tests fail'
type: boolean
required: false
default: false

jobs:
test:
name: Test 🧪
runs-on: ubuntu-latest
timeout-minutes: 30
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha || github.sha}}

- name: Docker API Build
run: docker build -t test -f Dockerfile-test .

- name: Docker API Test Run
run: docker run -e CHECK_CODEGEN=true test

deploy-to-dev:
name: Deploy to Development 🚧
needs: test
if: github.event_name == 'push' && github.ref_name == 'main'
concurrency: dev
uses: './.github/workflows/deploy.yml'
with:
environment: dev
secrets: inherit

deploy-to-prod:
name: Deploy to Production 🌟
needs: test
if: github.event_name == 'release'
concurrency: prod
uses: './.github/workflows/deploy.yml'
with:
environment: prod
secrets: inherit

manual-deployment:
name: Manual Deployment ‼️
needs: test
if: github.event_name == 'workflow_dispatch' && (success() || inputs.force == true)
concurrency: ${{ inputs.environment }}
uses: './.github/workflows/deploy.yml'
with:
environment: ${{ inputs.environment }}
secrets: inherit
38 changes: 38 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# A reusable workflow that deploys the contents of a repository to a target environment.
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow

on:
workflow_call:
inputs:
environment:
type: string
required: true

jobs:
deploy:
name: 🚀
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'

- name: Install dependencies
run: npm install --no-save

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.DEPLOYMENT_ROLE_ARN }}
role-session-name: ${{ github.actor }}
aws-region: ${{ vars.AWS_REGION || 'us-west-2' }}

- name: Deploy
run: npm run deploy-${{ inputs.environment }}
28 changes: 0 additions & 28 deletions .github/workflows/test.yml

This file was deleted.

Loading