aprs.me/.github/workflows/deploy.yml
Graham McIntire abc6ebe798
Restore FluxCD auto-deployment via GitOps
Replace direct kubectl deployment with GitOps pattern:
- Build and push to git.mcintire.me registry using built-in token
- Commit updated image tag in k8s/deployment.yaml after each build
- FluxCD picks up the manifest change and handles the k8s rollout
- Remove Tailscale, kubectl, and ghcr.io dependencies
2026-02-18 16:15:43 -06:00

84 lines
2.3 KiB
YAML

name: Build and Deploy
on:
push:
branches: [main]
# Cancel in-progress runs when a new run is triggered
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: git.mcintire.me
IMAGE: git.mcintire.me/graham/aprs.me
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image_tag: ${{ steps.tag.outputs.image_tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Compute image tag
id: tag
run: |
TIMESTAMP=$(date +%s)
SHA=${GITHUB_SHA:0:7}
echo "image_tag=main-${TIMESTAMP}-${SHA}" >> "$GITHUB_OUTPUT"
- name: Log in to registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.IMAGE }}:${{ steps.tag.outputs.image_tag }}
${{ env.IMAGE }}:main
cache-from: type=registry,ref=${{ env.IMAGE }}:main
cache-to: type=inline
deploy:
needs: build-and-push
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update image in deployment manifest
run: |
NEW_IMAGE="${{ env.IMAGE }}:${{ needs.build-and-push.outputs.image_tag }}"
sed -i "s|image: git.mcintire.me/graham/aprs.me:.*|image: ${NEW_IMAGE}|g" k8s/deployment.yaml
- name: Commit and push updated manifest
run: |
NEW_IMAGE="${{ env.IMAGE }}:${{ needs.build-and-push.outputs.image_tag }}"
git config user.name "github-actions"
git config user.email "github-actions@github.com"
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 ${NEW_IMAGE} [skip ci]"
git push