diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 2d417bb..92caaad 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -47,15 +47,6 @@ jobs: tags: | type=raw,value=latest - # - name: Setup Docker Metadata - # id: meta - # uses: docker/metadata-action@v4 - # with: - # images: liamsgit.dev/LiamPietralla/code-snippets - # tags: | - # type=raw,value=latest - # type=sha,value=${{ github.sha }} - - name: Login to Registry uses: docker/login-action@v3 with: @@ -86,16 +77,10 @@ jobs: with: nomad_version: '1.10.5' - # - name: Deploy Job to Nomad - # run: | - # nomad job run -var="version=${{ github.sha }}" infra/nomad/code-snippets.nomad.hcl - # env: - # NOMAD_ADDR: ${{ vars.NOMAD_ADDR }} - # NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }} - - name: Deploy Job to Nomad run: | - nomad job run infra/nomad/code-snippets.nomad.hcl + export DEPLOYMENT_VERSION="${GITHUB_SHA:0:7}-$(date +%s)" + nomad job run -var="deployment_version=$DEPLOYMENT_VERSION" infra/nomad/code-snippets.nomad.hcl env: NOMAD_ADDR: ${{ vars.NOMAD_ADDR }} NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }} diff --git a/infra/nomad/code-snippets.nomad.hcl b/infra/nomad/code-snippets.nomad.hcl index 5a48a6f..1ae0491 100644 --- a/infra/nomad/code-snippets.nomad.hcl +++ b/infra/nomad/code-snippets.nomad.hcl @@ -1,12 +1,17 @@ -variable "version" { - type = string - default = "latest" +variable "deployment_version" { + type = string + description = "The deployment version from CI/CD" + default = "unknown" } job "code-snippets" { datacenters = ["dc1"] type = "service" + meta { + version = var.deployment_version + } + constraint { operator = "=" attribute = "${meta.machine_role}" @@ -26,7 +31,7 @@ job "code-snippets" { driver = "docker" config { - image = "liamsgit.dev/liampietralla/code-snippets:${var.version}" + image = "liamsgit.dev/liampietralla/code-snippets:latest" force_pull = true ports = ["http"] }