Communication API Pipeline #18
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: Communication API Pipeline | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- src/Communication/**/* | |
- k8s/charts/communication-api/**/* | |
- src/BuildingBlocks/Shared/**/* | |
- .github/workflows/communication-api.yml | |
jobs: | |
deploy: | |
name: Deploy Communication API | |
runs-on: ubuntu-latest | |
env: | |
# Google Cloud variables | |
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} | |
PROJECT_NAME: promag | |
REGION: us-central1 | |
LOCATION: us-central1-a | |
# Docker variables | |
IMAGE: communication-api | |
DOCKERFILE_PATH: ./src/Communication/Communication.Api/Dockerfile | |
# Kubernetes variables | |
CLUSTER_NAME: sit-cluster | |
NAMESPACE: prod | |
CHART: communication-api | |
DEPLOYMENT: communication-api | |
VALUES_FILE: values.yaml | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install the GCloud CLI | |
uses: google-github-actions/setup-gcloud@v0 | |
with: | |
project_id: ${{ secrets.GOOGLE_PROJECT }} | |
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
install_components: "gke-gcloud-auth-plugin" | |
export_default_credentials: true | |
- name: Configure Docker for authentication | |
run: |- | |
gcloud --quiet auth configure-docker $REGION-docker.pkg.dev | |
- name: Build Docker image | |
run: |- | |
docker build \ | |
--tag "$REGION-docker.pkg.dev/$GOOGLE_PROJECT/$PROJECT_NAME/$IMAGE:latest" \ | |
-f $DOCKERFILE_PATH \ | |
. | |
- name: Push Docker image | |
run: |- | |
docker push "$REGION-docker.pkg.dev/$GOOGLE_PROJECT/$PROJECT_NAME/$IMAGE:latest" | |
- name: Install Helm | |
run: | | |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash | |
- name: Deploy to GKE | |
run: |- | |
gcloud container clusters get-credentials $CLUSTER_NAME --location $LOCATION | |
sed -i "s|REPOSITORY_PATH|$REGION-docker.pkg.dev/$GOOGLE_PROJECT/$PROJECT_NAME/$IMAGE|g" k8s/charts/$CHART/$VALUES_FILE | |
helm upgrade --install --namespace $NAMESPACE -f k8s/charts/$CHART/$VALUES_FILE $CHART k8s/charts/$CHART |