Skip to content

Commit

Permalink
fest : terragunt
Browse files Browse the repository at this point in the history
  • Loading branch information
RTae committed Mar 2, 2024
1 parent 2f4a506 commit e319e4a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 34 deletions.
82 changes: 50 additions & 32 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,62 @@ jobs:
# ==============
# CI task
# ==============
build-and-push-image:
environment: dev
name: Build Docker image and push to repositories
runs-on: ubuntu-latest
# build-and-push-image:
# environment: dev
# name: Build Docker image and push to repositories
# runs-on: ubuntu-latest

strategy:
matrix:
module:
[
backend,
frontend
]
# strategy:
# matrix:
# module:
# [
# backend,
# frontend
# ]

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
# steps:
# - name: "Checkout"
# uses: "actions/checkout@v3"

- name: Add image tags
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
# - name: Add image tags
# run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV

- id: "auth"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"
# - id: "auth"
# uses: "google-github-actions/auth@v1"
# with:
# credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
# - name: "Set up Cloud SDK"
# uses: "google-github-actions/setup-gcloud@v1"

- name: "Use gcloud CLI"
run: "gcloud info"
# - name: "Use gcloud CLI"
# run: "gcloud info"

- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
# - name: "Docker auth"
# run: |-
# gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet

# - name: Build image
# run: docker build -f Dockerfile -t ${{ env.GAR_LOCATION }}/${{ matrix.module }}:${{ env.SHORT_SHA }} .
# working-directory: ${{ matrix.module }}

- name: Build image
run: docker build -f Dockerfile -t ${{ env.GAR_LOCATION }}/${{ matrix.module }}:${{ env.SHORT_SHA }} .
working-directory: ${{ matrix.module }}
# - name: Push image
# run: docker push ${{ env.GAR_LOCATION }}/${{ matrix.module }}:${{ env.SHORT_SHA }}

- name: Push image
run: docker push ${{ env.GAR_LOCATION }}/${{ matrix.module }}:${{ env.SHORT_SHA }}
deploy:
environment: dev
name: Build Docker image and push to repositories
runs-on: ubuntu-latest
container:
image: alpine/terragrunt
steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Run Terragrunt"
working-directory: "terraform"
run: |-
cat ${SERVICE_ACCOUNT_KEY} > gcloud-sa-key.json
cat gcloud-sa-key.json
export GOOGLE_CREDENTIALS="./gcloud-sa-key.json"
export IMAGE_TAG=${{ env.SHORT_SHA }}
5 changes: 3 additions & 2 deletions terraform/configs/dev/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ terraform {
locals {
project_id = "personal-388003"
location = "asia-southeast1"
image_tag = get_env("IMAGE_TAG", "latest")
}

inputs = {
project_id = local.project_id
location = local.location

backend_image_name = "gcr.io/cloudrun/hello"
frontend_image_name = "gcr.io/cloudrun/hello"
backend_image_name = "asia-southeast1-docker.pkg.dev/personal-388003/demo-registry-gar/backend:${image_tag}"
frontend_image_name = "asia-southeast1-docker.pkg.dev/personal-388003/demo-registry-gar/frontend:${image_tag}"
}

0 comments on commit e319e4a

Please sign in to comment.