Files
n8n/.gitea/workflows/ci.yml
T
chemavx b9ce8e2090
CI/CD / build-and-push (push) Successful in 1m39s
ci: migrate to buildx docker-container driver with standalone buildkitd
2026-04-22 20:40:08 +00:00

80 lines
2.5 KiB
YAML

name: CI/CD
on:
push:
branches:
- main
env:
REGISTRY: gitea.gitea.svc.cluster.local:3000
K8S_MANIFESTS_REPO: http://chemavx:${{ secrets.CI_TOKEN }}@gitea.gitea.svc.cluster.local:3000/chemavx/k8s-manifests.git
GIT_SSL_NO_VERIFY: "true"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ssl-verify: false
- name: Set image tag
id: tag
run: echo "TAG=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
- name: Log in to registry
run: echo "${{ secrets.CI_TOKEN }}" | docker login gitea.gitea.svc.cluster.local:3000 -u chemavx --password-stdin
- name: Create buildx builder
run: |
cat > /tmp/buildkitd.toml << 'EOF'
[registry."registry-cache.registry-cache.svc.cluster.local:5000"]
http = true
insecure = true
[registry."gitea.gitea.svc.cluster.local:3000"]
http = true
insecure = true
[registry."docker.io"]
mirrors = ["registry-cache.registry-cache.svc.cluster.local:5000"]
EOF
docker buildx create \
--name ci-builder \
--driver docker-container \
--driver-opt network=host \
--config /tmp/buildkitd.toml \
--use
docker buildx inspect --bootstrap
- name: Build and push n8n image
run: |
TAG=${{ steps.tag.outputs.TAG }}
docker buildx build \
--builder ci-builder \
--cache-from type=registry,ref=gitea.gitea.svc.cluster.local:3000/chemavx/n8n:buildcache \
--cache-to type=registry,ref=gitea.gitea.svc.cluster.local:3000/chemavx/n8n:buildcache,mode=max \
-t gitea.gitea.svc.cluster.local:3000/chemavx/n8n:${TAG} \
--push \
-f Dockerfile .
- name: Update k8s manifests
run: |
TAG=${{ steps.tag.outputs.TAG }}
git config --global user.email "ci@git.chemavx.xyz"
git config --global user.name "Gitea CI"
git clone ${{ env.K8S_MANIFESTS_REPO }} /tmp/k8s-manifests
cd /tmp/k8s-manifests
sed -i "s|image: .*n8n.*|image: git.chemavx.xyz/chemavx/n8n:${TAG}|g" \
n8n/deployment-n8n.yaml
sed -i "s|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|g" \
n8n/deployment-n8n.yaml
git add n8n/deployment-n8n.yaml
git diff --cached --quiet || git commit -m "ci: update n8n image to ${TAG} [skip ci]"
git push