ecab227b8d
Build and Deploy / build-and-push (push) Successful in 21s
The CI bot was committing image-tag bumps back to master after every Docker build, which forced a `git pull --rebase` before every developer push. Moving the kustomization commit to a dedicated `deploy` branch keeps master clean — the build bot no longer diverges it. Argo CD / Flux should now watch the `deploy` branch (targetRevision: deploy) instead of master. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
77 lines
2.4 KiB
YAML
77 lines
2.4 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
paths:
|
|
- 'solitaire_server/**'
|
|
- 'solitaire_sync/**'
|
|
- 'solitaire_core/**'
|
|
- 'Cargo.toml'
|
|
- 'Cargo.lock'
|
|
- '.gitea/workflows/docker-build.yml'
|
|
|
|
env:
|
|
REGISTRY: git.aleshym.co
|
|
IMAGE: git.aleshym.co/funman300/solitaire-server
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
# Need full history so we can push the tag-update commit back.
|
|
fetch-depth: 0
|
|
token: ${{ secrets.CI_TOKEN }}
|
|
|
|
- name: Set image tag
|
|
id: meta
|
|
run: echo "sha=${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Log in to Gitea registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.CI_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
driver-opts: network=host
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: solitaire_server/Dockerfile
|
|
push: true
|
|
tags: |
|
|
${{ env.IMAGE }}:${{ steps.meta.outputs.sha }}
|
|
${{ env.IMAGE }}:latest
|
|
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
|
|
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
|
|
|
|
- name: Install kustomize
|
|
run: |
|
|
curl -sL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.4.3/kustomize_v5.4.3_linux_amd64.tar.gz | tar xz
|
|
sudo mv kustomize /usr/local/bin/kustomize
|
|
|
|
- name: Pin image tag and push to deploy branch
|
|
run: |
|
|
git config user.email "ci@gitea.local"
|
|
git config user.name "Gitea CI"
|
|
# Switch to the deploy branch, creating it from the current HEAD if absent.
|
|
git fetch origin deploy 2>/dev/null && git checkout deploy || git checkout -b deploy
|
|
# Update the pinned image tag.
|
|
cd deploy
|
|
kustomize edit set image solitaire-server=${{ env.IMAGE }}:${{ steps.meta.outputs.sha }}
|
|
cd ..
|
|
git add deploy/kustomization.yaml
|
|
git diff --cached --quiet && exit 0
|
|
git commit -m "chore(deploy): bump image to ${{ steps.meta.outputs.sha }} [skip ci]"
|
|
git push origin deploy
|