Merge remote-tracking branch 'origin/add-date-validation' #12
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: Build and Deploy to GKE | |
on: | |
push: | |
branches: | |
- main | |
env: | |
PROJECT_ID: ${{ secrets.GKE_PROJECT }} | |
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }} | |
GKE_ZONE: ${{ secrets.GKE_ZONE }} # Add your cluster zone here. | |
IMAGE_GTFS_VALIDATOR: gtfs-validator | |
jobs: | |
setup-build-publish-deploy: | |
name: Setup, Build, Publish, and Deploy | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Setup gcloud CLI | |
- name: Setup Google Cloud CLI | |
uses: google-github-actions/[email protected] | |
with: | |
service_account_key: ${{ secrets.GCP_SA_KEY}} | |
project_id: ${{ secrets.GKE_PROJECT }} | |
# Configure Docker to use the gcloud command-line tool as a credential | |
# helper for authentication | |
- run: |- | |
gcloud --quiet auth configure-docker | |
# Get the GKE credentials so we can deploy to the cluster | |
- uses: google-github-actions/[email protected] | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER }} | |
location: ${{ env.GKE_ZONE }} | |
credentials: ${{ secrets.GCP_SA_KEY }} | |
# Build the Docker image | |
- name: Build | |
run: |- | |
docker build \ | |
--tag "gcr.io/$PROJECT_ID/$IMAGE_GTFS_VALIDATOR:$GITHUB_SHA" \ | |
-f Dockerfile \ | |
. | |
# Push the Docker image to Google Container Registry | |
- name: Publish | |
run: |- | |
docker push "gcr.io/$PROJECT_ID/$IMAGE_GTFS_VALIDATOR:$GITHUB_SHA" | |
# Set up kustomize | |
- name: Set up Kustomize | |
run: |- | |
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64 | |
chmod u+x ./kustomize | |
# Deploy the Docker image to the GKE cluster | |
- name: Deploy | |
run: |- | |
envsubst < deployment.yaml > deployment.yml | |
kubectl apply -n gtfs-validator -f deployment.yml | |
kubectl get services -n gtfs-validator -o wide |