1212 description : " If true, pull will be done from thehiveproject/cortex docker hub repo"
1313 default : false
1414 pull_request :
15- types : [ labeled ]
15+ types : [ labeled, synchronize ]
1616
1717# Here we define if we should go with a pr-XXX deployment version, or a vXXX (release) version
1818# this depends on the event name
2222 deployment_version : ${{ github.event_name == 'pull_request' && format('{0}-{1}', 'pr', github.event.number) || format('{0}{1}', 'v', inputs.docker_image_version) }}
2323
2424concurrency :
25- group : ${{ github.workflow }}-${{ github.ref }}
25+ group : deploy- ${{ github.workflow }}-${{ github.ref }}
2626 cancel-in-progress : true
2727
2828jobs :
29+ build :
30+ if : ${{ (github.event.label.name == 'ci:deploy' || contains(github.event.pull_request.labels.*.name, 'ci:deploy')) || github.event_name == 'workflow_dispatch' }}
31+ uses : ./.github/workflows/build.docker.yml
32+ with :
33+ is_prod : false
34+ override_version : ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}
35+ secrets : inherit
36+
2937 prepare :
38+ needs :
39+ - build
3040 runs-on :
3141 - linux
3242 outputs :
5060 DV2=$(echo $DV | sed 's/\.//g')
5161 echo rewriten_deployment_version=$(echo $DV2 | sed 's/-//g') >> $GITHUB_OUTPUT
5262 deploy :
53- if : ${{ github.event.label.name == 'ci:deploy' || github.event_name == 'workflow_dispatch' }}
63+ if : ${{ ( github.event.label.name == 'ci:deploy' || contains(github.event.pull_request.labels.*.name, 'ci:deploy')) || github.event_name == 'workflow_dispatch' }}
5464 needs :
5565 - prepare
5666 permissions :
@@ -70,20 +80,64 @@ jobs:
7080 secrets : |
7181 /nomad-dev/creds/developers-token-dev secret_id | NOMAD_TOKEN;
7282 - uses : actions/checkout@v4
83+
84+ - name : Setup Nomad CLI
85+ uses : hashicorp/setup-nomad@main
86+
7387 - name : Setup `nomad-pack`
7488 uses : hashicorp/setup-nomad-pack@main
7589 id : setup
90+
91+ - name : Verify installations
92+ run : |
93+ nomad version
94+ nomad-pack version
95+
7696 - name : Deploy job using Nomad Pack
7797 id : run
7898 # We pass two different version variables: one for Docker pull, the other for Nomad services
7999 run : |
80- nomad-pack run -var from_docker_hub=${{ inputs.from_docker_hub }} \
100+ nomad-pack run -var from_docker_hub=${{ inputs.from_docker_hub || false }} \
81101 -var docker_image="${{ vars.SB_GHCR }}/cortex" \
82- -var docker_image_version=${{ inputs.docker_image_version || env.deployment_version }} \
102+ -var docker_image_version=${{ needs.build.outputs.image_version || inputs.docker_image_version || env.deployment_version }} \
83103 -var service_version=${{ needs.prepare.outputs.expected_deployment_version }} ./deployment/nomad/packs/cortex
84104 env :
85105 NOMAD_ADDR : " http://10.30.4.180:4646"
86106 NOMAD_TOKEN : " ${{ env.NOMAD_TOKEN }}"
107+
108+ - name : Wait for deployment to be healthy
109+ run : |
110+ JOB_NAME="cortex-${{ needs.prepare.outputs.expected_deployment_version }}"
111+ echo "Waiting for deployment of job: $JOB_NAME"
112+
113+ # Get the latest deployment ID
114+ DEPLOYMENT_ID=$(nomad job deployments -json "$JOB_NAME" | jq -r '.[0].ID')
115+
116+ if [ "$DEPLOYMENT_ID" = "null" ] || [ -z "$DEPLOYMENT_ID" ]; then
117+ echo "No deployment found for job $JOB_NAME"
118+ exit 1
119+ fi
120+
121+ echo "Monitoring deployment: $DEPLOYMENT_ID"
122+
123+ # Monitor the deployment status with polling every 10 seconds
124+ nomad deployment status -monitor -wait 10s "$DEPLOYMENT_ID"
125+
126+ # Check final deployment status
127+ DEPLOYMENT_STATUS=$(nomad deployment status -json "$DEPLOYMENT_ID" | jq -r '.Status')
128+
129+ if [ "$DEPLOYMENT_STATUS" = "successful" ]; then
130+ echo "✅ Deployment completed successfully!"
131+ exit 0
132+ else
133+ echo "❌ Deployment failed with status: $DEPLOYMENT_STATUS"
134+ exit 1
135+ fi
136+ env :
137+ NOMAD_ADDR : " http://10.30.4.180:4646"
138+ NOMAD_TOKEN : " ${{ env.NOMAD_TOKEN }}"
139+ continue-on-error : false
140+
87141 setup :
88142 needs :
89143 - prepare
0 commit comments