mirror of
https://github.com/FranzDiebold/github-env-vars-action.git
synced 2024-12-27 17:34:51 -05:00
Expose pull request id as CI_PR_NUMBER and CI_PR_ID
Right now the closest this action offers `CI_REF_NAME_SLUG` which is `42-merge`, but its not clean and more importantly cannot be used in numerical contexts which would benefit from having that as `42`. if current event is not a pull-request, it should be empty
This commit is contained in:
parent
3ca94d3749
commit
ad0bd50c16
2 changed files with 9 additions and 0 deletions
|
@ -30,6 +30,8 @@ A [GitHub Action](https://github.com/features/actions) to expose useful environm
|
|||
| `CI_BASE_REF` | Only set for forked repositories / pull request. The branch of the base repository / the base branch name. Copy of `GITHUB_BASE_REF` - for reasons of completeness. | `main` |
|
||||
| `CI_SHA_SHORT` | The shortened commit SHA (8 characters) that triggered the workflow. | `ffac537e` |
|
||||
| `CI_SHA` | The commit SHA that triggered the workflow. Copy of `GITHUB_SHA` - for reasons of completeness. | `ffac537e6cbbf934b08745a378932722df287a53` |
|
||||
| `CI_PR_NUMBER` | The number of the pull request. Only set for pull requests. | `42` |
|
||||
| `CI_PR_ID` | Copy of `CI_PR_NUMBER` for completeness. | `42` |
|
||||
| `CI_PR_TITLE` | The title of the pull request. Only set for pull requests. | `Add feature xyz.` |
|
||||
| `CI_PR_DESCRIPTION` | The description of the pull request. Only set for pull requests. | `The feature xyz is the [...]` |
|
||||
| `CI_ACTOR` | The name of the person or app that initiated the workflow. Copy of `GITHUB_ACTOR` - for reasons of completeness. | `octocat` |
|
||||
|
|
7
index.js
7
index.js
|
@ -186,6 +186,13 @@ try {
|
|||
const pullRequest = github.context.payload &&
|
||||
github.context.payload.pull_request;
|
||||
if (pullRequest) {
|
||||
const prNumber = pullRequest.number;
|
||||
core.exportVariable('CI_PR_NUMBER', prNumber);
|
||||
core.info(`Set CI_PR_NUMBER=${process.env.CI_PR_NUMBER}`);
|
||||
|
||||
core.exportVariable('CI_PR_ID', prNumber);
|
||||
core.info(`Set CI_PR_ID=${process.env.CI_PR_ID}`);
|
||||
|
||||
const prTitle = pullRequest.title;
|
||||
core.exportVariable('CI_PR_TITLE', prTitle);
|
||||
core.info(`Set CI_PR_TITLE=${process.env.CI_PR_TITLE}`);
|
||||
|
|
Loading…
Reference in a new issue