Aggiungi il file di workflow per il deploy su GKE
Some checks failed
GKE Deploy / build-and-deploy (push) Failing after 9s
Some checks failed
GKE Deploy / build-and-deploy (push) Failing after 9s
This commit is contained in:
51
.gitea/workflows/main.yml
Normal file
51
.gitea/workflows/main.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
name: GKE Deploy
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
PROJECT_ID: deployments-485614
|
||||
DOCKER_HOST: tcp://localhost:2375
|
||||
REGION: europe-west1
|
||||
REPO_NAME: gitea-repo # Assicurati di aver creato questo repo su Artifact Registry!
|
||||
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
|
||||
|
||||
# 1. Login su Google Cloud
|
||||
- name: Google Auth
|
||||
uses: google-github-actions/auth@v1
|
||||
with:
|
||||
credentials_json: ${{ secrets.GCP_SA_KEY }}
|
||||
|
||||
# 2. Setup Strumenti Google
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v1
|
||||
|
||||
# 3. Configura Docker per Google
|
||||
- name: Docker Auth
|
||||
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
|
||||
|
||||
# 4. Build e Push dell'immagine
|
||||
- name: Build and Push
|
||||
run: |
|
||||
# Costruiamo il tag completo dell'immagine
|
||||
IMAGE_TAG=${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}
|
||||
|
||||
# Costruiamo e carichiamo
|
||||
docker build -t $IMAGE_TAG .
|
||||
docker push $IMAGE_TAG
|
||||
|
||||
# 5. Aggiorna Kubernetes
|
||||
- name: Deploy to GKE
|
||||
run: |
|
||||
gcloud components install gke-gcloud-auth-plugin
|
||||
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.CLUSTER_ZONE }}
|
||||
|
||||
# Aggiorna l'immagine nel deployment esistente
|
||||
kubectl set image deployment/demo-app demo-container=${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}
|
||||
Reference in New Issue
Block a user