name: CI on: push: branches: [main] pull_request: branches: [main] env: REGISTRY: registry.i80.dk IMAGE: registry.i80.dk/gitea/ilsp jobs: build-and-push: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set image tag id: tag run: echo "tag=${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT" - name: Log in to registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_TOKEN }} - name: Build and push uses: docker/build-push-action@v5 with: context: . push: ${{ github.ref == 'refs/heads/main' }} tags: | ${{ env.IMAGE }}:${{ steps.tag.outputs.tag }} ${{ env.IMAGE }}:latest cache-from: type=registry,ref=${{ env.IMAGE }}:latest cache-to: type=inline deploy: runs-on: ubuntu-latest needs: build-and-push if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 - name: Set image tag id: tag run: echo "tag=${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT" - name: Deploy to Nomad run: | scp ilsp.nomad ${{ secrets.DEPLOY_HOST }}:/tmp/ilsp.nomad ssh ${{ secrets.DEPLOY_HOST }} \ "NOMAD_ADDR=https://nomad.i80.dk:4646 nomad job run \ -var='image_tag=${{ steps.tag.outputs.tag }}' /tmp/ilsp.nomad" - name: Health check run: | sleep 20 curl -sf https://ilsp.i80.dk/health | jq .