ci: Add concurrency option #45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: User Image Build | |
env: | |
SERVICE_NAME: user-service | |
BUILD_ID: ${{ github.sha }}-${{ github.run_id }} | |
HELM_VALUE: user-service-chart/values-dev.yaml | |
HELM_BRANCH: dev | |
on: | |
push: | |
branches: | |
- 'develop' | |
paths: | |
- 'user-service/**' | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
- name: Google Cloud Auth | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Configure Docker Authentication | |
run: gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev --quiet | |
- name: Build, tag, and push docker image to Google Artifact Registry | |
env: | |
IMAGE_TAG: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.REPO_NAME }}/${{ env.SERVICE_NAME }}:${{ env.BUILD_ID }} | |
run: | | |
docker build -f ./user-service/user-application/app-api/Dockerfile -t $IMAGE_TAG . | |
docker push $IMAGE_TAG | |
- name: Checkout Helm Repository | |
uses: actions/checkout@v4 | |
with: | |
repository: quizy-web/quizy-helm-charts | |
path: helm-chart | |
ref: ${{ env.HELM_BRANCH }} | |
ssh-key: ${{ secrets.HELM_REPO_SSH_KEY }} | |
- name: Change Image tag of the Helm Chart | |
uses: mikefarah/[email protected] | |
with: | |
cmd: yq -i '.image.tag = "${{ env.BUILD_ID }}"' helm-chart/${{ env.HELM_VALUE }} | |
- name: Commit and Push Helm Chart Changes | |
run: | | |
cd helm-chart | |
git config --local user.email "[email protected]" | |
git config --local user.name "githubaction" | |
git add ${{ env.HELM_VALUE }} | |
git commit -m "Update ${SERVICE_NAME} image tag to ${{ env.BUILD_ID }}" | |
git push --force origin ${{ env.HELM_BRANCH }} |