https://github.com/hmknapp/github-actions-matrix-run-id
Fetches the current workflow run ID of a matrix job from the GitHub API
https://github.com/hmknapp/github-actions-matrix-run-id
Last synced: about 1 year ago
JSON representation
Fetches the current workflow run ID of a matrix job from the GitHub API
- Host: GitHub
- URL: https://github.com/hmknapp/github-actions-matrix-run-id
- Owner: HMKnapp
- License: other
- Created: 2020-10-28T15:59:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-28T19:58:53.000Z (over 5 years ago)
- Last Synced: 2024-03-22T21:34:55.596Z (about 2 years ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# github-actions-matrix-run-id
Fetches the current workflow run ID of a matrix job from the GitHub API
**Pull Requests welcome!**
## Setup
### Environment Variables
`MATRIX_ID` *required*
`GH_TOKEN` *conditional* PAT is required only for private repositories
### Example Workflow
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 }}
```
## Usage
### Install
```
npm install 'HMKnapp/github-actions-matrix-run-id#master'
```
### Use via CLI
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
```
### Use as Module
Example
```js
const { getRunID } = require("github-actions-matrix-run-id");
async function printID() {
const id = await getRunID();
console.log(id);
}
printID();
```
## Known Limitations
Issues getting ID for Pull Request runs