Fetches the current workflow run ID of a matrix job from the GitHub API
Pull Requests welcome!
MATRIX_ID
required
GH_TOKEN
conditional PAT is required only for private repositories
Matrix
jobs:
Runs:
strategy:
matrix:
example_run: [run_one, run_two]
Pass Matrix job ID to environment
steps:
- name: Build
run: npm run build
env:
MATRIX_ID: ${{ matrix.example_run }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
npm install 'HMKnapp/github-actions-matrix-run-id#master'
Output: Numeric run ID
node ./node_modules/github-actions-matrix-run-id/index.js
> 1234567890
Optional: Add parameter --url
to get full URL
node ./node_modules/github-actions-matrix-run-id/index.js --url
> https://github.com/HMKnapp/github-actions-matrix-run-id/runs/1234567890
Example
const { getRunID } = require("github-actions-matrix-run-id");
async function printID() {
const id = await getRunID();
console.log(id);
}
printID();
Issues getting ID for Pull Request runs