From abc6ebe7985055afc84162f4e9963d765340bfa9 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 18 Feb 2026 16:15:40 -0600 Subject: [PATCH] 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 --- .github/workflows/deploy.yml | 89 +++++++++++++----------------------- 1 file changed, 33 insertions(+), 56 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 873ff53..53375fa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,8 +10,8 @@ concurrency: cancel-in-progress: true env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + REGISTRY: git.mcintire.me + IMAGE: git.mcintire.me/graham/aprs.me jobs: build-and-push: @@ -19,6 +19,8 @@ jobs: permissions: contents: read packages: write + outputs: + image_tag: ${{ steps.tag.outputs.image_tag }} steps: - name: Checkout repository @@ -26,23 +28,20 @@ jobs: with: submodules: recursive - - name: Log in to the Container registry + - 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: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=sha,prefix={{branch}}- - type=raw,value=latest,enable={{is_default_branch}} - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -51,57 +50,35 @@ jobs: with: context: . push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + 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: Setup Tailscale - uses: tailscale/github-action@v2 + - name: Checkout repository + uses: actions/checkout@v4 with: - oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} - oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} - tags: tag:ci + token: ${{ secrets.GITHUB_TOKEN }} - - name: Set kubeconfig + - name: Update image in deployment manifest run: | - mkdir -p ~/.kube - echo "${{ secrets.TAILSCALE_KUBECONFIG }}" | base64 -d > ~/.kube/config - # Skip TLS verification for Tailscale IP connection - kubectl config set-cluster default --insecure-skip-tls-verify=true + 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: Deploy to K3s + - name: Commit and push updated manifest run: | - # Get current timestamp in ISO8601 format - DEPLOYED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ") - - # Create a temporary patch file with the deployment timestamp - cat > /tmp/deployed-at-patch.yaml <