name: Deploy to Nomad on: workflow_run: workflows: ["Build and Push Docker Image"] types: - completed workflow_dispatch: inputs: container_sha: description: 'Container SHA to deploy (leave empty for latest commit)' required: false type: string jobs: nomad: runs-on: ubuntu-latest name: Deploy to Nomad if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Setup Nomad CLI run: | NOMAD_VERSION="1.10.5" curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip unzip nomad.zip sudo mv nomad /usr/local/bin/ rm nomad.zip nomad version - 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 - name: Deploy Nomad Job id: deploy env: NOMAD_ADDR: http://192.168.4.36:4646 NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }} run: | echo "Deploying container version: ${{ steps.container_version.outputs.sha }}" nomad job run \ -var="container_sha=${{ steps.container_version.outputs.sha }}" \ navidrome-litefs.nomad