Deploy Sakura to Stage #334
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: Deploy Sakura to Stage | |
on: [workflow_dispatch] | |
jobs: | |
deploy-sakura: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout build tools | |
uses: actions/checkout@v4 | |
with: | |
repository: lolibrary/build | |
token: ${{ secrets.PAT }} | |
ref: cea7b09494c6541c8bdfc7d919e1d58428061117 | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: ${{ secrets.GCLOUD_SA_KEY }} | |
- name: GCloud setup | |
uses: 'google-github-actions/setup-gcloud@v1' | |
with: | |
project_id: ${{ secrets.GCLOUD_PROJECT_ID }} | |
- id: 'get-credentials' | |
uses: 'google-github-actions/get-gke-credentials@v1' | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER }} | |
location: ${{ env.GKE_ZONE }} | |
project_id: ${{ secrets.GCLOUD_PROJECT_ID }} | |
- name: GHCR login | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ github.actor }} | |
password: ${{ secrets.PAT }} | |
registry: ghcr.io | |
- name: Deploy | |
run: | | |
docker pull $DOCKER_WIKI_REPO:latest | |
export WIKI_TAG=$(docker image inspect -f "{{(index .RepoDigests 0)}}" $DOCKER_WIKI_REPO:latest) | |
cat "$(pwd)/manifests/stage.yml" | sed "s#PLACEHOLDER#\"$DOCKER_SHA_TAG\"#" | sed "s#WIKIHOLDER#\"$WIKI_TAG\"#" | kubectl apply --record -f - | |
kubectl rollout status "deployment/s-sakura" -n $NAMESPACE | |
env: | |
DOCKER_SHA_TAG: "ghcr.io/lolibrary/sakura:${{ github.sha }}" | |
DOCKER_WIKI_REPO: "ghcr.io/lolibrary/wiki" | |
PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} | |
NAMESPACE: "default" | |
GKE_CLUSTER: "staging" | |
GKE_ZONE: "us-central1-a" |