Some checks failed
Build & Deploy / deploy (push) Failing after 1s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
66 lines
2.3 KiB
YAML
66 lines
2.3 KiB
YAML
name: Build & Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set image tags
|
|
run: |
|
|
SHA=$(echo "${{ github.sha }}" | cut -c1-8)
|
|
echo "API_TAG=git.arthurbarre.fr/ordinarthur/ordinarthur-os-api:$SHA" >> $GITHUB_ENV
|
|
echo "PWA_TAG=git.arthurbarre.fr/ordinarthur/ordinarthur-os-pwa:$SHA" >> $GITHUB_ENV
|
|
|
|
- name: Login Gitea Container Registry
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
|
|
docker login git.arthurbarre.fr -u ordinarthur --password-stdin
|
|
|
|
- name: Build & push API
|
|
run: |
|
|
docker build -f apps/api/Dockerfile -t "$API_TAG" .
|
|
docker push "$API_TAG"
|
|
|
|
- name: Build & push PWA
|
|
run: |
|
|
docker build \
|
|
--build-arg VITE_API_BASE_URL=https://api.os.arthurbarre.fr \
|
|
-f apps/pwa/Dockerfile \
|
|
-t "$PWA_TAG" .
|
|
docker push "$PWA_TAG"
|
|
|
|
- name: Install kubectl
|
|
run: |
|
|
curl -LO "https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
|
chmod +x kubectl && mv kubectl /usr/local/bin/kubectl
|
|
|
|
- name: Deploy on K3s
|
|
env:
|
|
KUBECONFIG_DATA: ${{ secrets.KUBECONFIG }}
|
|
run: |
|
|
mkdir -p ~/.kube
|
|
echo "$KUBECONFIG_DATA" | base64 -d > ~/.kube/config
|
|
|
|
# Appliquer les manifests (idempotent)
|
|
kubectl apply -f deploy/k8s/namespace.yaml
|
|
kubectl apply -f deploy/k8s/pwa.deployment.yaml
|
|
kubectl apply -f deploy/k8s/api.deployment.yaml
|
|
|
|
# Pull secret (idempotent)
|
|
kubectl -n ordinarthur-os create secret docker-registry gitea-registry \
|
|
--docker-server=git.arthurbarre.fr \
|
|
--docker-username=ordinarthur \
|
|
--docker-password="${{ secrets.REGISTRY_PASSWORD }}" \
|
|
--dry-run=client -o yaml | kubectl apply -f -
|
|
|
|
# Rollout
|
|
kubectl -n ordinarthur-os set image deploy/api api=$API_TAG
|
|
kubectl -n ordinarthur-os set image deploy/pwa pwa=$PWA_TAG
|
|
kubectl -n ordinarthur-os rollout status deploy/api --timeout=120s
|
|
kubectl -n ordinarthur-os rollout status deploy/pwa --timeout=120s
|