fix: 調整使用說明文字內容 #10
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: pin-yi-project | |
GAR_LOCATION: asia-east1 | |
GKE_CLUSTER: cluster | |
GKE_ZONE: asia-east1-b | |
DEPLOYMENT_NAME: racing | |
REPOSITORY: pin-yi-image | |
IMAGE: racing | |
jobs: | |
setup-build-publish-deploy: | |
name: Setup, Build, Publish, and Deploy | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- id: "auth" | |
uses: "google-github-actions/auth@v2" | |
with: | |
credentials_json: "${{ secrets.GCP_CREDENTIALS }}" | |
- name: Docker configuration | |
run: |- | |
echo '${{ secrets.GCP_CREDENTIALS }}' | docker login -u _json_key --password-stdin https://$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 }} | |
- name: Build | |
run: |- | |
docker build \ | |
--tag "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$(echo $GITHUB_SHA | head -c7)" \ | |
--build-arg GITHUB_SHA="$GITHUB_SHA" \ | |
--build-arg GITHUB_REF="$GITHUB_REF" . | |
- name: Add Image Tag | |
run: docker tag $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$(echo $GITHUB_SHA | head -c7) $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:latest | |
- name: Publish | |
run: |- | |
docker push "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$(echo $GITHUB_SHA | head -c7)" && \ | |
docker push "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:latest" | |
- name: Set Image | |
run: |- | |
kubectl set image deployment/$DEPLOYMENT_NAME \ | |
racing="$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$(echo $GITHUB_SHA | head -c7)" -n $DEPLOYMENT_NAME | |
- name: Deploy | |
run: |- | |
kubectl rollout status deployment/$DEPLOYMENT_NAME -n $DEPLOYMENT_NAME | |
kubectl get services -o wide |