fix(communication): try fix static file issue on prod #28
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: | |
build: | |
name: Build & Test .NET projects | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_PATH: src/Communication/Communication.Api/Communication.Api.csproj | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install .NET SDK | |
uses: actions/setup-dotnet@v3.2.0 | |
with: | |
dotnet-version: 8.0.x | |
- name: Build .NET project with dependencies | |
run: |- | |
dotnet restore $PROJECT_PATH | |
dotnet build $PROJECT_PATH --no-restore | |
deploy: | |
name: Deploy Communication API | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
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" \ | |
--no-cache \ | |
-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 |