Compare commits
No commits in common. "4ea625f95c672149953a63ba030592b904390022" and "4de6055040e9e213436f4555af0120b523f5ca13" have entirely different histories.
4ea625f95c
...
4de6055040
@ -14,17 +14,16 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Instala kubectl + auth plugin (gcloud já vem via setup-gcloud).
|
||||
# Build é feito remoto via Cloud Build (não precisa Docker no runner).
|
||||
- name: Install kubectl + gke-auth-plugin
|
||||
# Imagem default do runner (node:18-bullseye) não traz docker CLI nem kubectl —
|
||||
# instalamos sob demanda. Eventualmente isso vai pra imagem custom do runner.
|
||||
- name: Install docker CLI + kubectl
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq apt-transport-https ca-certificates gnupg curl
|
||||
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
|
||||
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" > /etc/apt/sources.list.d/google-cloud-sdk.list
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq kubectl google-cloud-cli-gke-gcloud-auth-plugin
|
||||
kubectl version --client=true
|
||||
apt-get install -y -qq docker.io
|
||||
KVER=$(curl -sL https://dl.k8s.io/release/stable.txt)
|
||||
curl -sL "https://dl.k8s.io/release/${KVER}/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl
|
||||
chmod +x /usr/local/bin/kubectl
|
||||
docker --version && kubectl version --client=true
|
||||
|
||||
- name: Auth GCP
|
||||
uses: google-github-actions/auth@v2
|
||||
@ -36,16 +35,21 @@ jobs:
|
||||
with:
|
||||
project_id: ${{ secrets.GCP_PROJECT }}
|
||||
|
||||
- name: Build & push (Cloud Build, sem Docker local)
|
||||
- name: Configure Docker auth
|
||||
run: gcloud auth configure-docker ${{ secrets.AR_LOCATION }}-docker.pkg.dev --quiet
|
||||
|
||||
- name: Build image
|
||||
run: |
|
||||
IMG="${IMAGE_BASE}/${{ gitea.event.repository.name }}:lab-${{ gitea.run_number }}"
|
||||
gcloud builds submit --tag "$IMG" --project=${{ secrets.GCP_PROJECT }} --timeout=30m
|
||||
docker build --platform=linux/amd64 -t "$IMG" .
|
||||
echo "IMG=$IMG" >> $GITHUB_ENV
|
||||
|
||||
- name: Push image (apenas em push pra master/main)
|
||||
if: github.event_name == 'push'
|
||||
run: docker push "$IMG"
|
||||
|
||||
- name: Deploy hml2 (apenas em push pra master/main)
|
||||
if: github.event_name == 'push'
|
||||
env:
|
||||
USE_GKE_GCLOUD_AUTH_PLUGIN: "True"
|
||||
run: |
|
||||
gcloud container clusters get-credentials ${{ secrets.GKE_CLUSTER }} --region ${{ secrets.GKE_REGION }} --project ${{ secrets.GCP_PROJECT }}
|
||||
NS=${{ secrets.K8S_NAMESPACE }}
|
||||
@ -60,7 +64,7 @@ jobs:
|
||||
if kubectl get deployment "$DEPLOYMENT" -n "$NS" >/dev/null 2>&1; then
|
||||
CONTAINER=$(kubectl get deployment "$DEPLOYMENT" -n "$NS" -o jsonpath='{.spec.template.spec.containers[0].name}')
|
||||
kubectl set image deployment/"$DEPLOYMENT" -n "$NS" "$CONTAINER=$IMG"
|
||||
kubectl rollout status deployment/"$DEPLOYMENT" -n "$NS" --timeout=600s
|
||||
kubectl rollout status deployment/"$DEPLOYMENT" -n "$NS" --timeout=300s
|
||||
else
|
||||
echo "Deployment $DEPLOYMENT não existe no ns $NS — pulei set image (provavelmente é o 1º deploy e o kubectl apply acabou de criar)"
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user