merge stage (#62) #31
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: Prod CI/CD Pipeline | |
on: | |
push: | |
branches: ['prod'] | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
GAR_LOCATION: us-west1 | |
GKE_CLUSTER: leap-prod | |
GKE_ZONE: us-west1 | |
DEPLOYMENT_NAME: observatory-service-prod | |
IMAGE: observatory-service | |
REPOSITORY: backend | |
jobs: | |
setup-build-publish-deploy: | |
name: Setup, Build, Publish, and Deploy | |
runs-on: ubuntu-latest | |
environment: prod | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Authenticate with Google Cloud | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: ewogICJ0eXBlIjogInNlcnZpY2VfYWNjb3VudCIsCiAgInByb2plY3RfaWQiOiAibGVhcC0zOTM1MDgiLAogICJwcml2YXRlX2tleV9pZCI6ICJlMDljNjUzMmY4MjA1MTRmNWNlMTc0ODZlMTU0ZGNkNzM3YmRlYjIxIiwKICAicHJpdmF0ZV9rZXkiOiAiLS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tXG5NSUlFdkFJQkFEQU5CZ2txaGtpRzl3MEJBUUVGQUFTQ0JLWXdnZ1NpQWdFQUFvSUJBUUNNVWhSNHIwZjlDbllCXG5yUHVKQU9tSUNOSEp2YWs5VDNZdWpiNHFpNkhZL01sc2VMTWpNRVlGUEZJbjB5QTYrVi83VVZBMDdhdkZGYWF0XG5ON1B0WXNLY1dXOVpPVm1qUWJJZS9lOGcyYkRuUEhJck5CQW03eS9Da2pheDlDa1QxMkF3RUZnKzMzR1NuUXIxXG5VL0dIT2c4LzJtTXI0TWp5eXZzazQxV01CZUs5UnpVdSsrelk1VUIxMzV3WHNkSHBTY3UybFFQbVBPT0E5RVdaXG5hcjFFbFZkS1BidU9kQT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GgyL2F1dGgiLAogICJ0b2tlbl91cmkiOiAiaHR0cHM6Ly9vYXV0aDIuZ29vZ2xlYXBpcy5jb20vdG9rZW4iLAogICJhdXRoX3Byb3ZpZGVyX3g1MDlfY2VydF91cmwiOiAiaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vb2F1dGgyL3YxL2NlcnRzIiwKICAiY2xpZW50X3g1MDlfY2VydF91cmwiOiAiaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vcm9ib3QvdjEvbWV0YWRhdGEveDUwOS9na2Utb3BlcmF0b3IlNDBsZWFwLTM5MzUwOC5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbSIsCiAgInVuaXZlcnNlX2RvbWFpbiI6ICJnb29nbGVhcGlzLmNvbSIKfQo= | |
- name: Configure Docker | |
run: gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev | |
- name: Set up GKE credentials | |
uses: google-github-actions/get-gke-credentials@v2 | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER }} | |
location: ${{ env.GKE_ZONE }} | |
project_id: ${{ env.PROJECT_ID }} | |
- name: Build Docker image | |
run: docker build -t ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:$GITHUB_SHA . | |
- name: Push Docker image to Artifact Registry | |
run: docker push ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:$GITHUB_SHA | |
- name: Deploy to GKE (Production) | |
run: | | |
cd k8s/production | |
sed -i "s|gcr.io/PROJECT_ID/observatory-service:TAG|${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:$GITHUB_SHA|" deployment.yaml | |
kubectl apply -f configmap.yaml | |
kubectl apply -f deployment.yaml | |
kubectl apply -f service.yaml | |
kubectl rollout status deployment/$DEPLOYMENT_NAME | |
kubectl get services -o wide | |
- name: Deploy HPA | |
run: kubectl apply -f k8s/production/hpa.yaml |