optimize #67
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: GitBook action | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
env: | |
GKE_CLUSTER: cluster-1 # Add your cluster name here. | |
GKE_ZONE: us-east1-b # Add your cluster zone here. | |
jobs: | |
docker-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Output Run Number | |
run: echo ${{ github.run_number }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
- run : | | |
docker build -t hamstershare/hamster-gitbook:latest . | |
docker push hamstershare/hamster-gitbook:latest | |
deploy: | |
needs: | |
- docker-build | |
name: deploy | |
runs-on: ubuntu-latest | |
environment: production | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- id: 'auth' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v1' | |
- id: 'get-credentials' | |
uses: 'google-github-actions/get-gke-credentials@v1' | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER }} | |
location: ${{ env.GKE_ZONE }} | |
# The KUBECONFIG env var is automatically exported and picked up by kubectl. | |
- name: 're deploy' | |
run: | | |
kubectl -n hamster rollout restart deployment gitbook |