ci: add Gitea Actions workflow with BuildKit
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Trigger BuildKit Build
|
||||
run: |
|
||||
echo "Building commit: $GITHUB_SHA"
|
||||
|
||||
# Delete old job
|
||||
kubectl delete job build-core-extensions-action -n gitea --ignore-not-found=true 2>/dev/null || true
|
||||
|
||||
# Create build job
|
||||
cat << EOF | kubectl apply -f -
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: build-core-extensions-action
|
||||
namespace: gitea
|
||||
spec:
|
||||
ttlSecondsAfterFinished: 86400
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
initContainers:
|
||||
- name: clone
|
||||
image: alpine/git:latest
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -e
|
||||
git clone --depth 1 http://gitea:3000/unchained/saleor-core-extensions.git /workspace
|
||||
cd /workspace && git checkout $GITHUB_SHA
|
||||
echo "Building: \$(git rev-parse --short HEAD)"
|
||||
volumeMounts:
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
||||
containers:
|
||||
- name: build
|
||||
image: moby/buildkit:latest
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -e
|
||||
mkdir -p /root/.docker
|
||||
cp /docker-config/.dockerconfigjson /root/.docker/config.json
|
||||
echo "Building with BuildKit..."
|
||||
buildctl --addr tcp://buildkit.gitea.svc.cluster.local:1234 build \ --frontend dockerfile.v0 \ --local context=/workspace \ --local dockerfile=/workspace \ --output type=image,name=ghcr.io/unchainedio/saleor-core-extensions:latest,push=true
|
||||
echo "Build complete! Triggering Flux..."
|
||||
kubectl annotate kustomization -n flux-system saleor --overwrite reconcile.fluxcd.io/requestedAt=\"$(date +%s)\"
|
||||
echo "Done!"
|
||||
volumeMounts:
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
||||
- name: docker-config
|
||||
mountPath: /docker-config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: workspace
|
||||
emptyDir: {}
|
||||
- name: docker-config
|
||||
secret:
|
||||
secretName: ghcr-pull-secret
|
||||
EOF
|
||||
|
||||
echo "Build job created!"
|
||||
kubectl wait --for=condition=complete job/build-core-extensions-action -n gitea --timeout=600s || echo "Build running in background"
|
||||
Reference in New Issue
Block a user