Skip to content

ci: update dockerfile #4

ci: update dockerfile

ci: update dockerfile #4

name: Dev - Build and Push to Artifact Registry
on:
push:
branches:
- 'develop'
- 'cicd'
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
AR_REGION: asia-southeast1
REPOSITORY: icy
IMAGE_NAME: backend
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Set up Cloud SDK
uses: 'google-github-actions/setup-gcloud@v0'
- name: Configure Docker
run: |
gcloud auth configure-docker ${{ env.AR_REGION }}-docker.pkg.dev --quiet
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push final Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
${{ env.AR_REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.AR_REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
# Setup kustomize
- name: Setup kustomize
run: |
curl -o kustomize --location https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize
mv kustomize /tmp
- name: Checkout dwarvesf/infrastructure
uses: actions/checkout@master
with:
repository: dwarvesf/infrastructure
token: ${{ secrets.GH_PAT }}
path: ./infrastructure
ref: main
- name: Update api version
run: |
cd ./infrastructure/icy/backend/$K8S_ENVIRONMENT
git config user.name lmquang
git config user.email [email protected]
/tmp/kustomize edit set image ${{ env.AR_REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}=${{ env.AR_REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
git commit -am "[skip ci] icy-backend ${K8S_ENVIRONMENT} image update"
git push origin main