sync
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 40s

This commit is contained in:
2025-12-15 07:38:18 -08:00
parent 9b445546da
commit 6ce170e84a
3 changed files with 32 additions and 6 deletions

View File

@@ -12,6 +12,9 @@ jobs:
permissions: permissions:
contents: read contents: read
packages: write packages: write
outputs:
container_sha: ${{ github.sha }}
registry_url: ${{ steps.registry.outputs.url }}
steps: steps:
- name: Checkout repository - name: Checkout repository

View File

@@ -6,13 +6,18 @@ on:
types: types:
- completed - completed
workflow_dispatch: # Allows manual triggering for testing workflow_dispatch: # Allows manual triggering for testing
inputs:
container_sha:
description: 'Container SHA to deploy (leave empty for latest commit)'
required: false
type: string
jobs: jobs:
nomad: nomad:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Deploy to Nomad name: Deploy to Nomad
# Only run if the build workflow succeeded
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
steps: steps:
# 1. Checkout Code # 1. Checkout Code
@@ -25,13 +30,27 @@ jobs:
with: with:
version: '1.10.0' # Use your desired version or remove for 'latest' version: '1.10.0' # Use your desired version or remove for 'latest'
# 3. Deploy the Nomad Job # 3. Determine container version to deploy
- name: Set Container Version
id: container_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.container_sha }}" ]; then
echo "sha=${{ inputs.container_sha }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "workflow_run" ]; then
echo "sha=${{ github.event.workflow_run.head_sha }}" >> $GITHUB_OUTPUT
else
echo "sha=${{ github.sha }}" >> $GITHUB_OUTPUT
fi
# 4. Deploy the Nomad Job
- name: Deploy Nomad Job - name: Deploy Nomad Job
id: deploy id: deploy
env: env:
# REQUIRED: Set the Nomad server address # REQUIRED: Set the Nomad server address
NOMAD_ADDR: http://nomad.service.dc1.consul:4646 NOMAD_ADDR: http://nomad.service.dc1.consul:4646
run: | run: |
echo "Deploying container version: ${{ steps.container_version.outputs.sha }}"
nomad status nomad status
nomad job run fitbit-garmin-sync.nomad nomad job run \
-var="container_version=${{ steps.container_version.outputs.sha }}" \
fitbit-garmin-sync.nomad

View File

@@ -1,3 +1,7 @@
variable "container_version" {
default = "latest"
}
job "fitbit-garmin-sync" { job "fitbit-garmin-sync" {
datacenters = ["dc1"] datacenters = ["dc1"]
type = "service" type = "service"
@@ -9,7 +13,7 @@ job "fitbit-garmin-sync" {
driver = "docker" driver = "docker"
config { config {
image = "gitea.service.dc1.fbleagh.duckdns.org/sstent/fitbit_garmin_sync:latest" image = "gitea.service.dc1.fbleagh.duckdns.org/sstent/fitbit_garmin_sync:${var.container_version}"
volumes = [ volumes = [
"/mnt/Public/configs/fitbit-garmin-sync:/app/data" "/mnt/Public/configs/fitbit-garmin-sync:/app/data"
] ]