Files
PunktFri/.gitea/workflows/deploy.yml
Henrik Jess Nielsen dfb937e7cc
All checks were successful
Build and Deploy PunktFri / build-and-deploy (push) Successful in 1m7s
CI: force Nomad redeploy by injecting SHA image tag
2026-04-28 21:50:10 +02:00

73 lines
2.1 KiB
YAML

name: Build and Deploy PunktFri
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: debian-host
env:
PATH: /usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin:/snap/bin
DOCKER_HOST: unix:///var/run/docker.sock
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Verify Docker
run: docker --version
- name: Log in to Harbor Registry
run: |
echo "${{ secrets.HARBOR_ROBOT_TOKEN }}" | docker login registry.i80.dk -u "robot\$gitserver" --password-stdin
- name: Build and push Docker image
run: |
docker build \
--build-arg BUILD_VERSION=${{ github.ref_name }}-${{ github.sha }} \
--build-arg GIT_COMMIT=${{ github.sha }} \
--build-arg BUILD_TIME=${{ github.event.head_commit.timestamp }} \
-t registry.i80.dk/gitea/punktfri:latest \
-t registry.i80.dk/gitea/punktfri:${{ github.sha }} \
-f ./Dockerfile \
.
docker push registry.i80.dk/gitea/punktfri:latest
docker push registry.i80.dk/gitea/punktfri:${{ github.sha }}
- name: Validate Nomad job
run: nomad job validate punktfri.nomad
env:
NOMAD_ADDR: "https://nomad.i80.dk:4646"
- name: Deploy to Nomad
run: |
# Inject the specific image SHA so Nomad always sees a change
sed -i "s|registry.i80.dk/gitea/punktfri:latest|registry.i80.dk/gitea/punktfri:${{ github.sha }}|g" punktfri.nomad
nomad job run -detach=false punktfri.nomad
env:
NOMAD_ADDR: "https://nomad.i80.dk:4646"
- name: Wait for deployment
run: |
sleep 15
nomad job status punktfri
echo "=== Allocations ==="
nomad job allocs punktfri
env:
NOMAD_ADDR: "https://nomad.i80.dk:4646"
- name: Health check
run: |
sleep 20
curl -f https://punktfri.i80.dk/health || echo "Service not yet available"
- name: Notify deployment status
run: |
echo "Deployment completed!"
echo "Service: https://punktfri.i80.dk"
echo "Health: https://punktfri.i80.dk/health"