Skip to content
Merged
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/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CD

on:
push:
branches: [main]
paths:
- "app/**"
- "k8s/**"
- ".github/workflows/cd.yaml"

permissions:
id-token: write
contents: write

concurrency:
group: prod-deploy
cancel-in-progress: true

env:
AWS_REGION: eu-west-1
ECR_REPOSITORY: data-pipeline-app

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Configure AWS credentials with OIDC
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME }}

- name: Login to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and push image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./app
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

- name: Install kustomize
run: |
curl -sL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.4.1/kustomize_v5.4.1_linux_amd64.tar.gz | tar xz
sudo mv kustomize /usr/local/bin/kustomize

- name: Update prod image tag
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
cd k8s/overlays/prod
kustomize edit set image data-pipeline-app=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

- name: Commit manifest change
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add k8s/overlays/prod/kustomization.yaml
git commit -m "deploy: image ${{ github.sha }}" || echo "No changes"
git push
37 changes: 37 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
pull_request:
branches: [main]
paths:
- "app/**"
- ".github/workflows/ci.yaml"
push:
branches: [main]
paths:
- "app/**"
- ".github/workflows/ci.yaml"

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r app/requirements.txt
pip install pytest httpx

- name: Run tests
working-directory: app
run: pytest -q

- name: Docker build check
run: docker build -t data-pipeline-app-ci ./app
51 changes: 51 additions & 0 deletions .github/workflows/infra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Terraform

on:
pull_request:
branches: [main]
paths:
- "terraform/**"
- ".github/workflows/infra.yaml"
push:
branches: [main]
paths:
- "terraform/**"
- ".github/workflows/infra.yaml"

permissions:
id-token: write
contents: read

env:
AWS_REGION: eu-west-1

jobs:
terraform:
runs-on: ubuntu-latest
defaults:
run:
working-directory: terraform

steps:
- uses: actions/checkout@v4

- name: Configure AWS credentials with OIDC
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME }}

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3

- name: Terraform Init
run: terraform init

- name: Terraform Fmt
run: terraform fmt -check

- name: Terraform Validate
run: terraform validate

- name: Terraform Plan
run: terraform plan -no-color -input=false
46 changes: 0 additions & 46 deletions terraform/cicd_gitops.tf

This file was deleted.

4 changes: 2 additions & 2 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ variable "aws_region" {
variable "github_owner" {
description = "GitHub owner or organization name"
type = string
default = "yooseongjin527"
default = "masondev1024"
}

variable "github_repo" {
description = "GitHub repository name"
type = string
default = "asac_de2_infra_1st"
default = "my-data-platform"
}

variable "github_branch" {
Expand Down
Loading