From b955ef30ad3e0f5055edf5691f7e94e7f514424e Mon Sep 17 00:00:00 2001 From: Franz Diebold Date: Fri, 4 Dec 2020 07:14:10 +0100 Subject: [PATCH] Add more environment variables. --- .github/workflows/demo.yml | 27 +++++++++++++++++++++------ README.md | 17 ++++++++++++++++- dist/index.js | 20 ++++++++++++++++++++ index.js | 20 ++++++++++++++++++++ package-lock.json | 2 +- package.json | 2 +- 6 files changed, 79 insertions(+), 9 deletions(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index ea02009..aed5d81 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -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" diff --git a/README.md b/README.md index 1e5b9af..a279116 100644 --- a/README.md +++ b/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.
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 diff --git a/dist/index.js b/dist/index.js index 86e47cf..a1f75ed 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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); } diff --git a/index.js b/index.js index 8328eb9..a253919 100644 --- a/index.js +++ b/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); } diff --git a/package-lock.json b/package-lock.json index fa88a23..e854b33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "github-env-vars-action", - "version": "2.0.0", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 80717c2..7b0c400 100644 --- a/package.json +++ b/package.json @@ -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": {