mirror of
https://github.com/FranzDiebold/github-env-vars-action.git
synced 2024-12-27 17:34:51 -05:00
Add more environment variables.
This commit is contained in:
parent
4a75e8cecb
commit
b955ef30ad
6 changed files with 79 additions and 9 deletions
27
.github/workflows/demo.yml
vendored
27
.github/workflows/demo.yml
vendored
|
@ -29,6 +29,11 @@ jobs:
|
|||
echo "CI_SHA_SHORT=$CI_SHA_SHORT"
|
||||
echo "CI_SHA=$CI_SHA"
|
||||
echo "CI_ACTOR=$CI_ACTOR"
|
||||
echo "CI_EVENT_NAME=$CI_EVENT_NAME"
|
||||
echo "CI_RUN_ID=$CI_RUN_ID"
|
||||
echo "CI_RUN_NUMBER=$CI_RUN_NUMBER"
|
||||
echo "CI_WORKFLOW=$CI_WORKFLOW"
|
||||
echo "CI_ACTION=$CI_ACTION"
|
||||
- name: Print environment variables exposed by GitHub
|
||||
run: |
|
||||
echo "GITHUB_ACTOR=$GITHUB_ACTOR"
|
||||
|
@ -37,11 +42,11 @@ jobs:
|
|||
echo "GITHUB_REF=$GITHUB_REF"
|
||||
echo "GITHUB_HEAD_REF=$GITHUB_HEAD_REF"
|
||||
echo "GITHUB_BASE_REF=$GITHUB_BASE_REF"
|
||||
echo "GITHUB_RUN_ID=$GITHUB_RUN_ID"
|
||||
echo "GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME"
|
||||
echo "GITHUB_ACTION=$GITHUB_ACTION"
|
||||
echo "GITHUB_RUN_ID=$GITHUB_RUN_ID"
|
||||
echo "GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER"
|
||||
echo "GITHUB_WORKFLOW=$GITHUB_WORKFLOW"
|
||||
echo "GITHUB_ACTION=$GITHUB_ACTION"
|
||||
|
||||
windows:
|
||||
name: Windows Demo
|
||||
|
@ -69,6 +74,11 @@ jobs:
|
|||
echo "CI_SHA_SHORT=$Env:CI_SHA_SHORT"
|
||||
echo "CI_SHA=$Env:CI_SHA"
|
||||
echo "CI_ACTOR=$Env:CI_ACTOR"
|
||||
echo "CI_EVENT_NAME=$Env:CI_EVENT_NAME"
|
||||
echo "CI_RUN_ID=$Env:CI_RUN_ID"
|
||||
echo "CI_RUN_NUMBER=$Env:CI_RUN_NUMBER"
|
||||
echo "CI_WORKFLOW=$Env:CI_WORKFLOW"
|
||||
echo "CI_ACTION=$Env:CI_ACTION"
|
||||
- name: Print environment variables exposed by GitHub
|
||||
run: |
|
||||
echo "GITHUB_ACTOR=$Env:GITHUB_ACTOR"
|
||||
|
@ -77,11 +87,11 @@ jobs:
|
|||
echo "GITHUB_REF=$Env:GITHUB_REF"
|
||||
echo "GITHUB_HEAD_REF=$Env:GITHUB_HEAD_REF"
|
||||
echo "GITHUB_BASE_REF=$Env:GITHUB_BASE_REF"
|
||||
echo "GITHUB_RUN_ID=$Env:GITHUB_RUN_ID"
|
||||
echo "GITHUB_EVENT_NAME=$Env:GITHUB_EVENT_NAME"
|
||||
echo "GITHUB_ACTION=$Env:GITHUB_ACTION"
|
||||
echo "GITHUB_RUN_ID=$Env:GITHUB_RUN_ID"
|
||||
echo "GITHUB_RUN_NUMBER=$Env:GITHUB_RUN_NUMBER"
|
||||
echo "GITHUB_WORKFLOW=$Env:GITHUB_WORKFLOW"
|
||||
echo "GITHUB_ACTION=$Env:GITHUB_ACTION"
|
||||
|
||||
macos:
|
||||
name: macOS Demo
|
||||
|
@ -109,6 +119,11 @@ jobs:
|
|||
echo "CI_SHA_SHORT=$CI_SHA_SHORT"
|
||||
echo "CI_SHA=$CI_SHA"
|
||||
echo "CI_ACTOR=$CI_ACTOR"
|
||||
echo "CI_EVENT_NAME=$CI_EVENT_NAME"
|
||||
echo "CI_RUN_ID=$CI_RUN_ID"
|
||||
echo "CI_RUN_NUMBER=$CI_RUN_NUMBER"
|
||||
echo "CI_WORKFLOW=$CI_WORKFLOW"
|
||||
echo "CI_ACTION=$CI_ACTION"
|
||||
- name: Print environment variables exposed by GitHub
|
||||
run: |
|
||||
echo "GITHUB_ACTOR=$GITHUB_ACTOR"
|
||||
|
@ -117,8 +132,8 @@ jobs:
|
|||
echo "GITHUB_REF=$GITHUB_REF"
|
||||
echo "GITHUB_HEAD_REF=$GITHUB_HEAD_REF"
|
||||
echo "GITHUB_BASE_REF=$GITHUB_BASE_REF"
|
||||
echo "GITHUB_RUN_ID=$GITHUB_RUN_ID"
|
||||
echo "GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME"
|
||||
echo "GITHUB_ACTION=$GITHUB_ACTION"
|
||||
echo "GITHUB_RUN_ID=$GITHUB_RUN_ID"
|
||||
echo "GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER"
|
||||
echo "GITHUB_WORKFLOW=$GITHUB_WORKFLOW"
|
||||
echo "GITHUB_ACTION=$GITHUB_ACTION"
|
||||
|
|
17
README.md
17
README.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
[![GitHub Action: View on Marketplace](https://img.shields.io/badge/GitHub%20Action-View_on_Marketplace-28a745?logo=github)](https://github.com/marketplace/actions/github-environment-variables-action)
|
||||
[![Demo: available](https://img.shields.io/badge/Demo-available-orange)](.github/workflows/demo.yml)
|
||||
[![Version: v2.0.0](https://img.shields.io/badge/Version-v2.0.0-brightgreen)](https://github.com/FranzDiebold/github-env-vars-action/releases/tag/v2.0.0)
|
||||
[![Version: v2.1.0](https://img.shields.io/badge/Version-v2.1.0-brightgreen)](https://github.com/FranzDiebold/github-env-vars-action/releases/tag/v2.1.0)
|
||||
[![Lint and Test](https://github.com/FranzDiebold/github-env-vars-action/workflows/Lint%20and%20Test/badge.svg)](https://github.com/FranzDiebold/github-env-vars-action/actions?query=workflow%3A%22Lint+and+Test%22)
|
||||
[![license: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](./LICENSE)
|
||||
|
||||
|
@ -31,6 +31,11 @@ A [GitHub Action](https://github.com/features/actions) to expose useful environm
|
|||
| `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_ACTOR` | The name of the person or app that initiated the workflow. Copy of `GITHUB_ACTOR` - for reasons of completeness. | `octocat` |
|
||||
| `CI_EVENT_NAME` | The name of the webhook event that triggered the workflow. Copy of `GITHUB_EVENT_NAME` - for reasons of completeness. | `push` or `pull_request` |
|
||||
| `CI_RUN_ID` | A unique number for each run within a repository. This number does not change if you re-run the workflow run. Copy of `GITHUB_RUN_ID` - for reasons of completeness. | `397746731` |
|
||||
| `CI_RUN_NUMBER` | A unique number for each run of a particular workflow in a repository. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run. Copy of `GITHUB_RUN_NUMBER` - for reasons of completeness. | `73` |
|
||||
| `CI_WORKFLOW` | The name of the workflow. Copy of `GITHUB_WORKFLOW` - for reasons of completeness. | `Demo` |
|
||||
| `CI_ACTION` | The unique identifier (`id`) of the action. Copy of `GITHUB_ACTION` - for reasons of completeness. | `run2` |
|
||||
|
||||
> The [slugified](https://en.wikipedia.org/wiki/Clean_URL#Slug) values are designed to be used in a URL.
|
||||
|
||||
|
@ -46,6 +51,11 @@ For a full list of default environment variables exposed by GitHub see [https://
|
|||
| `GITHUB_REF` | The branch or tag ref that triggered the workflow. <br>If neither a branch or tag is available for the event type, the variable will not exist. | `refs/heads/feat/feature-branch-1` |
|
||||
| `GITHUB_HEAD_REF` | Only set for forked repositories / pull request. The branch of the head repository / the head branch name. | `feat/feature-branch-1` |
|
||||
| `GITHUB_BASE_REF` | Only set for forked repositories / pull request. The branch of the base repository / the base branch name. | `main` |
|
||||
| `GITHUB_EVENT_NAME` | The name of the webhook event that triggered the workflow. | `push` |
|
||||
| `GITHUB_RUN_ID` | A unique number for each run within a repository. This number does not change if you re-run the workflow run. | `397746731` |
|
||||
| `GITHUB_RUN_NUMBER` | A unique number for each run of a particular workflow in a repository. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run. | `73` |
|
||||
| `GITHUB_WORKFLOW` | The name of the workflow. | `Demo` |
|
||||
| `GITHUB_ACTION` | The unique identifier (`id`) of the action. | `run2` |
|
||||
|
||||
## :rocket: Example usage
|
||||
|
||||
|
@ -73,6 +83,11 @@ steps:
|
|||
echo "CI_SHA_SHORT=$CI_SHA_SHORT"
|
||||
echo "CI_SHA=$CI_SHA"
|
||||
echo "CI_ACTOR=$CI_ACTOR"
|
||||
echo "CI_EVENT_NAME=$CI_EVENT_NAME"
|
||||
echo "CI_RUN_ID=$CI_RUN_ID"
|
||||
echo "CI_RUN_NUMBER=$CI_RUN_NUMBER"
|
||||
echo "CI_WORKFLOW=$CI_WORKFLOW"
|
||||
echo "CI_ACTION=$CI_ACTION"
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
|
20
dist/index.js
vendored
20
dist/index.js
vendored
|
@ -192,6 +192,26 @@ try {
|
|||
actor = process.env.GITHUB_ACTOR;
|
||||
core.exportVariable('CI_ACTOR', actor);
|
||||
core.info(`Set CI_ACTOR=${process.env.CI_ACTOR}`);
|
||||
|
||||
eventName = process.env.GITHUB_EVENT_NAME;
|
||||
core.exportVariable('CI_EVENT_NAME', eventName);
|
||||
core.info(`Set CI_EVENT_NAME=${process.env.CI_EVENT_NAME}`);
|
||||
|
||||
runId = process.env.GITHUB_RUN_ID;
|
||||
core.exportVariable('CI_RUN_ID', runId);
|
||||
core.info(`Set CI_RUN_ID=${process.env.CI_RUN_ID}`);
|
||||
|
||||
runNumber = process.env.GITHUB_RUN_NUMBER;
|
||||
core.exportVariable('CI_RUN_NUMBER', runNumber);
|
||||
core.info(`Set CI_RUN_NUMBER=${process.env.CI_RUN_NUMBER}`);
|
||||
|
||||
workflow = process.env.GITHUB_WORKFLOW;
|
||||
core.exportVariable('CI_WORKFLOW', workflow);
|
||||
core.info(`Set CI_WORKFLOW=${process.env.CI_WORKFLOW}`);
|
||||
|
||||
action = process.env.GITHUB_ACTION;
|
||||
core.exportVariable('CI_ACTION', action);
|
||||
core.info(`Set CI_ACTION=${process.env.CI_ACTION}`);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
|
20
index.js
20
index.js
|
@ -185,6 +185,26 @@ try {
|
|||
actor = process.env.GITHUB_ACTOR;
|
||||
core.exportVariable('CI_ACTOR', actor);
|
||||
core.info(`Set CI_ACTOR=${process.env.CI_ACTOR}`);
|
||||
|
||||
eventName = process.env.GITHUB_EVENT_NAME;
|
||||
core.exportVariable('CI_EVENT_NAME', eventName);
|
||||
core.info(`Set CI_EVENT_NAME=${process.env.CI_EVENT_NAME}`);
|
||||
|
||||
runId = process.env.GITHUB_RUN_ID;
|
||||
core.exportVariable('CI_RUN_ID', runId);
|
||||
core.info(`Set CI_RUN_ID=${process.env.CI_RUN_ID}`);
|
||||
|
||||
runNumber = process.env.GITHUB_RUN_NUMBER;
|
||||
core.exportVariable('CI_RUN_NUMBER', runNumber);
|
||||
core.info(`Set CI_RUN_NUMBER=${process.env.CI_RUN_NUMBER}`);
|
||||
|
||||
workflow = process.env.GITHUB_WORKFLOW;
|
||||
core.exportVariable('CI_WORKFLOW', workflow);
|
||||
core.info(`Set CI_WORKFLOW=${process.env.CI_WORKFLOW}`);
|
||||
|
||||
action = process.env.GITHUB_ACTION;
|
||||
core.exportVariable('CI_ACTION', action);
|
||||
core.info(`Set CI_ACTION=${process.env.CI_ACTION}`);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "github-env-vars-action",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "github-env-vars-action",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0",
|
||||
"description": "A GitHub Action to expose useful environment variables.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue