add workflow #1
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 to Kubernetes | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Google Cloud SDK | |
uses: google-github-actions/setup-gcloud@master | |
with: | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
export_default_credentials: true | |
- name: Configure Docker CLI | |
run: | | |
gcloud auth configure-docker | |
- name: Build and push Docker image | |
run: | | |
docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/your-image-name . | |
docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/your-image-name | |
- name: Set kubectl context | |
run: | | |
gcloud container clusters get-credentials ${{ secrets.GCP_CLUSTER_NAME }} --zone ${{ secrets.GCP_CLUSTER_ZONE }} --project ${{ secrets.GCP_PROJECT_ID }} | |
- name: Deploy to Kubernetes | |
run: | | |
kubectl apply -f path/to/your/kubernetes/config.yaml |