72 lines
2.2 KiB
YAML
72 lines
2.2 KiB
YAML
name: Deploy PHP
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: native
|
|
timeout-minutes: 5
|
|
|
|
steps:
|
|
- name: Sync content to PVC
|
|
run: |
|
|
kubectl -n sushi delete job camilou-sync --ignore-not-found=true --wait=true
|
|
|
|
cat <<'EOF' | kubectl apply -f -
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: camilou-sync
|
|
namespace: sushi
|
|
spec:
|
|
backoffLimit: 0
|
|
template:
|
|
spec:
|
|
restartPolicy: Never
|
|
containers:
|
|
- name: sync
|
|
image: alpine/git:latest
|
|
command: ["sh", "-c"]
|
|
args:
|
|
- |
|
|
set -eux
|
|
if [ -d /content/.git ]; then
|
|
git -C /content fetch --depth 1 origin main
|
|
git -C /content reset --hard origin/main
|
|
else
|
|
git clone --depth 1 https://git.alocoq.fr/sushi/Camilou.fr.git /content
|
|
fi
|
|
volumeMounts:
|
|
- name: content
|
|
mountPath: /content
|
|
volumes:
|
|
- name: content
|
|
persistentVolumeClaim:
|
|
claimName: camilou-content
|
|
EOF
|
|
|
|
- name: Wait for sync
|
|
run: |
|
|
kubectl -n sushi wait --for=condition=complete job/camilou-sync --timeout=300s
|
|
|
|
- name: Show sync logs
|
|
if: always()
|
|
run: |
|
|
kubectl -n sushi logs job/camilou-sync || true
|
|
|
|
- name: Apply configmap
|
|
run: |
|
|
git archive --remote=https://git.alocoq.fr/sushi/Camilou.fr.git HEAD configmap.yml | tar -x -O | kubectl apply -f -
|
|
|
|
- name: Restart deployment
|
|
run: |
|
|
kubectl -n sushi rollout restart deployment/sushi
|
|
kubectl -n sushi rollout status deployment/sushi --timeout=120s
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: |
|
|
kubectl -n sushi delete job camilou-sync --ignore-not-found=true --wait=true |