Build documentation #17
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 documentation | |
on: | |
workflow_dispatch: | |
inputs: | |
deployment_target: | |
type: choice | |
description: Deployment target | |
options: | |
- nodatime-test | |
- nodatime | |
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 | |
IMAGE: nodatime.org | |
steps: | |
- name: Check out nodatime.org | |
uses: actions/checkout@v4 | |
with: | |
path: nodatime.org | |
- name: Checkout nodatime | |
uses: actions/checkout@v4 | |
with: | |
repository: nodatime/nodatime | |
path: nodatime | |
- name: Checkout nodatime.serialization | |
uses: actions/checkout@v4 | |
with: | |
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 | |
- name: "Construct the image tag" | |
run: |- | |
echo "IMAGE_TAG=${REPOSITORY_ZONE}-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$IMAGE:$GITHUB_RUN_ID" >> $GITHUB_ENV | |
# 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 $IMAGE_TAG \ | |
-f nodatime.org/build/Dockerfile \ | |
. | |
# Push the Docker image to Google Artifact Registry | |
- name: Publish image | |
run: |- | |
docker push $IMAGE_TAG | |
- name: "Configure kubectl credentials" | |
uses: 'google-github-actions/get-gke-credentials@v2' | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER }} | |
location: ${{ env.GKE_ZONE }} | |
# Push to GKE (using the auth we've already configured) | |
- name: Update GKE test deployment | |
run: |- | |
kubectl set image deployment "${{ inputs.deployment_target }}" "${{ inputs.deployment_target }}"=$IMAGE_TAG |