Skip to content

Commit

Permalink
Add fetch_token with first build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tigloo committed Jul 25, 2024
1 parent f8c680d commit 06b0b02
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/compile_windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Compile fetch_token for Windows
on:
push:
branches: [ main ]
workflow_dispatch:

jobs:
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm -g install bun
- name: Compile fetch_token
working-directory: fetch_token
run: |
bun install
bun build ./fetch_token.js --compile --minify --outfile fetch_token.exe
- name: Commit & Push changes
uses: EndBug/add-and-commit@v9
with:
add: 'fetch_token/fetch_token.exe'
github_token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions fetch_token/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
if [ ! -d "bin" ]; then
mkdir bin
fi

bun install
bun build ./fetch_token.js --compile --minify --outfile fetch_token
16 changes: 16 additions & 0 deletions fetch_token/fetch_token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { DefaultAzureCredential } from "@azure/identity"

const args = process.argv

// remove program name from args
args.shift();
args.shift();

// Azure SDK clients accept the credential as a parameter
const credential = new DefaultAzureCredential()
const token = await credential.getToken(args)

console.log('TOKEN="' + token.token + '"')

// needed for bun to really terminate, otherwise hangs here
process.exit()
9 changes: 9 additions & 0 deletions fetch_token/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dependencies": {
"@azure/identity": "^4.0.0"
},
"type": "module",
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3"
}
}

0 comments on commit 06b0b02

Please sign in to comment.