Skip to content

Commit

Permalink
Try authenticating to Nomad
Browse files Browse the repository at this point in the history
  • Loading branch information
kberzinch committed Mar 3, 2024
1 parent 8de1c5b commit 36f26d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ jobs:
image-digest: ${{ steps.build.outputs.digest }}

deploy-test:
name: Deploy Test
name: Deploy
needs: [lint, test, docs, docker]
uses: ./.github/workflows/deploy.yml
if: ${{ github.ref == 'refs/heads/main' }}
Expand Down
28 changes: 7 additions & 21 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,13 @@ jobs:
- name: Setup Nomad
uses: lucasmelin/[email protected]

- name: Get JWT endpoint
id: script
uses: actions/github-script@v6
timeout-minutes: 1
- name: Exchange GitHub JWT for Nomad token
uses: mikenomitch/[email protected]
with:
script: |
const token = process.env['ACTIONS_RUNTIME_TOKEN']
const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL']
core.setOutput('TOKEN', token.trim())
core.setOutput('IDTOKENURL', runtimeUrl.trim())
url: https://nomad.bcdc.robojackets.net
jwtGithubAudience: https://nomad.bcdc.robojackets.net
methodName: GitHub

- name: Exchange GitHub token for JWT
id: jwt
- name: Run Nomad
run: |
IDTOKEN=$(curl -H "Authorization: bearer ${{steps.script.outputs.TOKEN}}" ${{steps.script.outputs.IDTOKENURL}} -H "Accept: application/json; api-version=2.0" -H "Content-Type: application/json" -d "{}" | jq -r '.value')
echo $IDTOKEN
jwtd() {
if [[ -x $(command -v jq) ]]; then
jq -R 'split(".") | .[0],.[1] | @base64d | fromjson' <<< "${1}"
echo "Signature: $(echo "${1}" | awk -F'.' '{print $3}')"
fi
}
jwtd $IDTOKEN
echo "${IDTOKEN}" >> $GITHUB_OUTPUT
nomad job status

0 comments on commit 36f26d6

Please sign in to comment.