ci: deploy via rollout restart instead of git-commit image bumps
Switch deployment to floating :main tag with imagePullPolicy: Always and have CI trigger a rollout restart directly via kubectl. Removes the [skip ci] image-bump commits from main's history. Requires a KUBECONFIG_DATA secret (base64-encoded kubeconfig with permission to restart deployment/aprs in the aprs namespace) in Forgejo Actions.
This commit is contained in:
parent
61fa83b3c4
commit
f093b1bb4b
2 changed files with 15 additions and 18 deletions
|
|
@ -45,20 +45,17 @@ jobs:
|
||||||
docker push "${IMAGE}:${TAG}"
|
docker push "${IMAGE}:${TAG}"
|
||||||
docker push "${IMAGE}:main"
|
docker push "${IMAGE}:main"
|
||||||
|
|
||||||
- name: Update deployment manifest
|
- name: Install kubectl
|
||||||
run: |
|
run: |
|
||||||
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
|
curl -sLO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||||
TAG="${{ steps.tag.outputs.tag }}"
|
install -m 0755 kubectl /usr/local/bin/kubectl
|
||||||
sed -i "s|image: ${IMAGE}:.*|image: ${IMAGE}:${TAG}|g" k8s/deployment.yaml
|
|
||||||
|
|
||||||
- name: Commit and push updated manifest
|
- name: Trigger rollout (no git commit)
|
||||||
|
env:
|
||||||
|
KUBECONFIG_DATA: ${{ secrets.KUBECONFIG_DATA }}
|
||||||
run: |
|
run: |
|
||||||
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
|
mkdir -p "$HOME/.kube"
|
||||||
TAG="${{ steps.tag.outputs.tag }}"
|
printf '%s' "$KUBECONFIG_DATA" | base64 -d > "$HOME/.kube/config"
|
||||||
git config user.name "FluxCD"
|
chmod 600 "$HOME/.kube/config"
|
||||||
git config user.email "fluxcd@w5isp.com"
|
kubectl -n aprs rollout restart deployment/aprs
|
||||||
git remote set-url origin https://x-token:${{ github.token }}@git.mcintire.me/graham/aprs.me.git
|
kubectl -n aprs rollout status deployment/aprs --timeout=5m
|
||||||
git add k8s/deployment.yaml
|
|
||||||
git diff --cached --quiet && echo "No changes to commit" && exit 0
|
|
||||||
git commit -m "chore: update aprs.me image to ${IMAGE}:${TAG} [skip ci]"
|
|
||||||
git push origin main
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ spec:
|
||||||
type: RuntimeDefault
|
type: RuntimeDefault
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: migrate
|
- name: migrate
|
||||||
image: git.mcintire.me/graham/aprs.me:main-1777403979-3f2e025
|
image: git.mcintire.me/graham/aprs.me:main
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
command: ["/app/bin/migrate"]
|
command: ["/app/bin/migrate"]
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
|
@ -82,8 +82,8 @@ spec:
|
||||||
cpu: "500m"
|
cpu: "500m"
|
||||||
containers:
|
containers:
|
||||||
- name: aprs
|
- name: aprs
|
||||||
image: git.mcintire.me/graham/aprs.me:main-1777403979-3f2e025
|
image: git.mcintire.me/graham/aprs.me:main
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
runAsNonRoot: true
|
runAsNonRoot: true
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue