All checks were successful
GKE Deploy / build-and-deploy (push) Successful in 21s
49 lines
1.6 KiB
YAML
49 lines
1.6 KiB
YAML
name: GKE Deploy
|
|
on: [push]
|
|
|
|
env:
|
|
PROJECT_ID: deployments-485614
|
|
REGION: europe-west1
|
|
REPO_NAME: gitea-repo
|
|
IMAGE_NAME: demo-app
|
|
CLUSTER_NAME: gitea-cluster
|
|
CLUSTER_ZONE: europe-west1-b
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Google Auth
|
|
uses: google-github-actions/auth@v1
|
|
with:
|
|
credentials_json: ${{ secrets.GCP_SA_KEY }}
|
|
|
|
# --- MODIFICA QUI ---
|
|
# Diciamo alla action di installare anche kubectl e il plugin auth
|
|
- name: Set up Cloud SDK
|
|
uses: google-github-actions/setup-gcloud@v1
|
|
with:
|
|
install_components: 'gke-gcloud-auth-plugin,kubectl'
|
|
# --------------------
|
|
|
|
- name: Docker Auth
|
|
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
|
|
|
|
- name: Build and Push
|
|
run: |
|
|
IMAGE_TAG=${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}
|
|
docker build -t $IMAGE_TAG .
|
|
docker push $IMAGE_TAG
|
|
|
|
# --- MODIFICA QUI ---
|
|
# Abbiamo rimosso 'gcloud components install...' perché ora lo fa lo step sopra
|
|
- name: Deploy to GKE
|
|
run: |
|
|
# Collega kubectl al cluster
|
|
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.CLUSTER_ZONE }}
|
|
|
|
# Ora kubectl esiste e funzionerà!
|
|
kubectl set image deployment/demo-app demo-container=${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }} |