Skip to content

Deploy - refs/heads/main #92

Deploy - refs/heads/main

Deploy - refs/heads/main #92

Workflow file for this run

name: Deploy
run-name: Deploy - ${{ github.ref }}
on:
workflow_dispatch:
push:
branches:
- main
concurrency: deploy
env:
INFRA_WORKSPACE_DEV: dev
INFRA_WORKSPACE_PRD: prd
INFRA_AWS_ROLE_DEV: arn:aws:iam::266302224431:role/mil-management-shd-role-github-milochaucom
INFRA_AWS_ROLE_PRD: arn:aws:iam::266302224431:role/mil-management-shd-role-github-milochaucom
INFRA_AWS_REGION: eu-west-3
PROJECT_API_SOLUTION: './src/cv-api/Milochau.CV.sln'
PROJECT_API_PUBLISH_FILTER: '*/bin/Release/net9.0/linux-x64/publish/bootstrap'
PROJECT_CLIENT_WORKSPACE: './src/cv-client'
DOTNET_VERSION: 9.0.x
jobs:
build_iac:
name: Build (IaC)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and test projects
uses: amilochau/github-actions/build/terraform@v4
build_api:
name: Build (API)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build AWS Lambda functions
uses: amilochau/github-actions/build/lambda-functions@v4
with:
dotnetVersion: ${{ env.DOTNET_VERSION }}
solutionPath: ${{ env.PROJECT_API_SOLUTION }}
publishPathFilter: ${{ env.PROJECT_API_PUBLISH_FILTER }}
build_client:
name: Build (Client)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build project
uses: amilochau/github-actions/build/node@v4
with:
projectWorkspace: ${{ env.PROJECT_CLIENT_WORKSPACE }}
- name: Upload artifact (compressed)
uses: actions/upload-artifact@v4
with:
name: build-node-compressed
path: ${{ env.PROJECT_CLIENT_WORKSPACE }}/dist
if-no-files-found: error
retention-days: 1
deploy_dev:
name: Deploy (DEV)
needs: [build_iac, build_api, build_client]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
environment: DEV
steps:
- uses: actions/checkout@v4
- name: Download artifact (API)
uses: actions/download-artifact@v4
with:
name: build-lambda-functions-compressed
- name: Download artifact (Client)
uses: actions/download-artifact@v4
with:
name: build-node-compressed
path: ${{ env.PROJECT_CLIENT_WORKSPACE }}/dist
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.INFRA_AWS_ROLE_DEV }}
aws-region: ${{ env.INFRA_AWS_REGION }}
- name: Deploy Terraform module
uses: amilochau/github-actions/deploy/terraform@v4
with:
workspaceName: ${{ env.INFRA_WORKSPACE_DEV }}
deploy_prd:
name: Deploy (PRD)
if: github.ref == 'refs/heads/main'
needs: [deploy_dev]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
environment: PRD
steps:
- uses: actions/checkout@v4
- name: Download artifact (API)
uses: actions/download-artifact@v4
with:
name: build-lambda-functions-compressed
- name: Download artifact (Client)
uses: actions/download-artifact@v4
with:
name: build-node-compressed
path: ${{ env.PROJECT_CLIENT_WORKSPACE }}/dist
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.INFRA_AWS_ROLE_PRD }}
aws-region: ${{ env.INFRA_AWS_REGION }}
- name: Deploy Terraform module
uses: amilochau/github-actions/deploy/terraform@v4
with:
workspaceName: ${{ env.INFRA_WORKSPACE_PRD }}
clean:
name: Clean
if: always()
needs: [deploy_prd]
runs-on: ubuntu-24.04
permissions:
actions: write
steps:
- name: Clean artifacts (API)
uses: amilochau/github-actions/clean/artifacts@v4
with:
runId: ${{ github.run_id }}