diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 6efdfb34..d57338c3 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -6,7 +6,14 @@ jobs: build-docs: runs-on: ubuntu-latest env: + PROJECT_ID: ${{ secrets.GKE_PROJECT }} DOTNET_NOLOGO: true + GKE_CLUSTER: web-cluster + GKE_ZONE: us-central1-a + REPOSITORY_ZONE: us-central1 + REPOSITORY_NAME: nodatime-org + DEPLOYMENT_NAME: nodatime-test + IMAGE: nodatime.org steps: - name: Check out nodatime.org @@ -26,8 +33,37 @@ jobs: repository: nodatime/nodatime.serialization path: nodatime.serialization + - name: Set up Google auth + uses: "google-github-actions/auth@v2" + with: + credentials_json: "${{ secrets.GKE_SA_KEY }}" + + - name: "Set up gcloud" + uses: "google-github-actions/setup-gcloud@v2" + + - name: "Configure Docker auth" + run: |- + gcloud auth configure-docker ${REPOSITORY_ZONE}-docker.pkg.dev --quiet + + # Note: we don't use GITHUB_SHA in the tag, as we have + # potentially three different relevant commits. - name: Docker build run: |- docker build \ + --tag "${REPOSITORY_ZONE}-docker.pkg.dev/$PROJECT_ID/$IMAGE:$GITHUB_RUN_ID" \ -f nodatime.org/build/Dockerfile \ - . \ No newline at end of file + . + + # Push the Docker image to Google Artifact Registry + - name: Publish + run: |- + docker push "${REPOSITORY_ZONE}-docker.pkg.dev/$PROJECT_ID/$IMAGE:$GITHUB_RUN_ID" + + # Get the GKE credentials so we can deploy to the cluster + - uses: google-github-actions/get-gke-credentials@db150f2cc60d1716e61922b832eae71d2a45938f + with: + cluster_name: ${{ env.GKE_CLUSTER }} + location: ${{ env.GKE_ZONE }} + credentials: ${{ secrets.GKE_SA_KEY }} + + # TODO: Update the (test) deployment