diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 420a524..c0202e4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -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 }} \ No newline at end of file + 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 }} \ No newline at end of file diff --git a/terraform/configs/dev/terragrunt.hcl b/terraform/configs/dev/terragrunt.hcl index ebc25c8..4b653f5 100644 --- a/terraform/configs/dev/terragrunt.hcl +++ b/terraform/configs/dev/terragrunt.hcl @@ -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}" } \ No newline at end of file