Skip to content

Commit

Permalink
Split up ci/cd into different GHA workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
choilmto committed Aug 25, 2024
1 parent 94bcaa0 commit d1ecd8c
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 101 deletions.
51 changes: 5 additions & 46 deletions .github/workflows/cicd.yml → .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: cicd
name: cd

on:
pull_request:
Expand All @@ -7,6 +7,7 @@ on:
jobs:
terraform_ecr:
name: Create or update ecr
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -25,21 +26,9 @@ jobs:
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.0"
-
name: Terraform fmt
id: fmt
run: terraform fmt -check
-
name: Initialize terraform
run: terraform init
-
name: Terraform Validate
id: validate
run: terraform validate -no-color
-
name: Terraform Plan
id: plan
run: terraform plan -no-color
-
name: Apply changes to terraform files
run: terraform apply -auto-approve
Expand All @@ -50,6 +39,7 @@ jobs:

dockerize:
name: Build and push Docker image
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
needs: terraform_ecr
outputs:
Expand All @@ -58,26 +48,6 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push jest tests
uses: docker/build-push-action@v6
with:
target: "test-jest"
tags: test-jest
load: true
-
name: Jest tests
run: docker run --rm test-jest
-
name: Build and push playwright tests
uses: docker/build-push-action@v6
with:
target: "test-playwright"
tags: test-playwright
load: true
-
name: Playwright tests
run: docker run --rm test-playwright
-
id: get_registry
name: Get registry
Expand All @@ -104,6 +74,7 @@ jobs:

terraform_app:
name: Create or update serverless services for app
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
needs: dockerize
env:
Expand All @@ -121,22 +92,10 @@ jobs:
name: Install terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.0"
-
name: Terraform fmt
id: fmt
run: terraform fmt -check
terraform_version: "1.9.0"
-
name: Initialize terraform
run: terraform init
-
name: Terraform Validate
id: validate
run: terraform validate -no-color
-
name: Terraform Plan
id: plan
run: terraform plan -no-color
-
name: Apply changes to terraform files
run: terraform apply -auto-approve
Expand Down
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: ci

on:
pull_request:
branches: main

jobs:
terraform_mgmt:
name: Check terraform files
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
defaults:
run:
working-directory: "./terraform/mgmt"
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Install terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.0"
-
name: Terraform fmt
id: fmt
run: terraform fmt -check
-
name: Initialize terraform
run: terraform init
-
name: Terraform Validate
id: validate
run: terraform validate -no-color
-
name: Terraform Plan
id: plan
run: terraform plan -no-color

docker:
name: Run automated testing inside docker
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push jest tests
uses: docker/build-push-action@v6
with:
target: "test-jest"
tags: test-jest
load: true
-
name: Jest tests
run: docker run --rm test-jest
-
name: Build and push playwright tests
uses: docker/build-push-action@v6
with:
target: "test-playwright"
tags: test-playwright
load: true
-
name: Playwright tests
run: docker run --rm test-playwright

terraform_prd:
name: Check terraform files
needs: terraform_mgmt
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
defaults:
run:
working-directory: "./terraform/prd"
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Install terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.0"
-
name: Terraform fmt
id: fmt
run: terraform fmt -check
-
name: Initialize terraform
run: terraform init
-
name: Terraform Validate
id: validate
run: terraform validate -no-color
-
name: Terraform Plan
id: plan
run: terraform plan -no-color
28 changes: 0 additions & 28 deletions .github/workflows/jest.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/playwright.yml

This file was deleted.

0 comments on commit d1ecd8c

Please sign in to comment.