gitea.d-ma.be port 22 is rejected (NPM only proxies HTTP/HTTPS). The runner runs on koala where the Gitea SSH NodePort 30022 is reachable locally. Use SSH config override instead of ssh-keyscan.
73 lines
2.4 KiB
YAML
73 lines
2.4 KiB
YAML
name: cd
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Build and deploy
|
|
runs-on: self-hosted
|
|
env:
|
|
SERVICE: supervisor
|
|
IMAGE: gitea.d-ma.be/mathias/supervisor
|
|
INFRA_REPO: git@gitea.d-ma.be:mathias/infra.git
|
|
BUILDKIT_HOST: unix:///run/buildkit/buildkitd.sock
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build and push image
|
|
run: |
|
|
set -e
|
|
trap 'rm -f /tmp/supervisor-image.tar' EXIT
|
|
IMAGE_TAG="${{ github.sha }}"
|
|
echo "Building ${IMAGE}:${IMAGE_TAG}"
|
|
|
|
# Build to local OCI tar (no registry auth needed at build time)
|
|
buildctl --addr "${BUILDKIT_HOST}" build \
|
|
--frontend dockerfile.v0 \
|
|
--local context=. \
|
|
--local dockerfile=. \
|
|
--opt build-arg:VERSION="${IMAGE_TAG}" \
|
|
--output type=oci,dest=/tmp/supervisor-image.tar
|
|
|
|
# Push with skopeo using simple credential flag (avoids OAuth token flow)
|
|
skopeo copy \
|
|
oci-archive:/tmp/supervisor-image.tar \
|
|
docker://${IMAGE}:${IMAGE_TAG} \
|
|
--dest-creds "${{ secrets.REGISTRY_CREDS }}"
|
|
|
|
echo "Built and pushed ${IMAGE}:${IMAGE_TAG}"
|
|
|
|
- name: Update infra repo
|
|
run: |
|
|
set -e
|
|
trap 'rm -rf /tmp/infra-update; rm -f ~/.ssh/infra_deploy_key' EXIT
|
|
IMAGE_TAG="${{ github.sha }}"
|
|
# Use internal Gitea SSH (runner is on koala — NodePort 30022 is reachable locally)
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.INFRA_DEPLOY_KEY }}" > ~/.ssh/infra_deploy_key
|
|
chmod 600 ~/.ssh/infra_deploy_key
|
|
cat >> ~/.ssh/config << 'SSHEOF'
|
|
Host gitea.d-ma.be
|
|
Port 30022
|
|
StrictHostKeyChecking no
|
|
SSHEOF
|
|
|
|
GIT_SSH_COMMAND="ssh -i ~/.ssh/infra_deploy_key -o IdentitiesOnly=yes" \
|
|
git clone "${INFRA_REPO}" /tmp/infra-update
|
|
|
|
cd /tmp/infra-update
|
|
sed -i "s|gitea.d-ma.be/mathias/supervisor:.*|gitea.d-ma.be/mathias/supervisor:${IMAGE_TAG}|" \
|
|
"k3s/apps/${SERVICE}/deployment.yaml"
|
|
|
|
git config user.email "cd-bot@d-ma.be"
|
|
git config user.name "CD Bot"
|
|
git add "k3s/apps/${SERVICE}/deployment.yaml"
|
|
git commit -m "chore(deploy): ${SERVICE} → ${IMAGE_TAG}"
|
|
GIT_SSH_COMMAND="ssh -i ~/.ssh/infra_deploy_key -o IdentitiesOnly=yes" \
|
|
git push
|
|
|
|
echo "Infra repo updated: ${SERVICE} → ${IMAGE_TAG}"
|