diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml
index 8e081bc..ea02009 100644
--- a/.github/workflows/demo.yml
+++ b/.github/workflows/demo.yml
@@ -7,22 +7,28 @@ jobs:
name: Linux Demo
runs-on: ubuntu-latest
steps:
- - uses: FranzDiebold/github-env-vars-action@v1.3.0
+ - uses: FranzDiebold/github-env-vars-action@v2
- name: Print environment variables exposed by this action
run: |
- echo "GITHUB_REPOSITORY_SLUG=$GITHUB_REPOSITORY_SLUG"
- echo "GITHUB_REPOSITORY_OWNER=$GITHUB_REPOSITORY_OWNER"
- echo "GITHUB_REPOSITORY_OWNER_SLUG=$GITHUB_REPOSITORY_OWNER_SLUG"
- echo "GITHUB_REPOSITORY_NAME=$GITHUB_REPOSITORY_NAME"
- echo "GITHUB_REPOSITORY_NAME_SLUG=$GITHUB_REPOSITORY_NAME_SLUG"
- echo "GITHUB_REF_SLUG=$GITHUB_REF_SLUG"
- echo "GITHUB_BRANCH_NAME=$GITHUB_BRANCH_NAME"
- echo "GITHUB_BRANCH_NAME_SLUG=$GITHUB_BRANCH_NAME_SLUG"
- echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
- echo "GITHUB_REF_NAME_SLUG=$GITHUB_REF_NAME_SLUG"
- echo "GITHUB_HEAD_REF_SLUG=$GITHUB_HEAD_REF_SLUG"
- echo "GITHUB_BASE_REF_SLUG=$GITHUB_BASE_REF_SLUG"
- echo "GITHUB_SHA_SHORT=$GITHUB_SHA_SHORT"
+ echo "CI_REPOSITORY_SLUG=$CI_REPOSITORY_SLUG"
+ echo "CI_REPOSITORY_OWNER=$CI_REPOSITORY_OWNER"
+ echo "CI_REPOSITORY_OWNER_SLUG=$CI_REPOSITORY_OWNER_SLUG"
+ echo "CI_REPOSITORY_NAME=$CI_REPOSITORY_NAME"
+ echo "CI_REPOSITORY_NAME_SLUG=$CI_REPOSITORY_NAME_SLUG"
+ echo "CI_REPOSITORY=$CI_REPOSITORY"
+ echo "CI_REF_SLUG=$CI_REF_SLUG"
+ echo "CI_ACTION_REF_NAME=$CI_ACTION_REF_NAME"
+ echo "CI_ACTION_REF_NAME_SLUG=$CI_ACTION_REF_NAME_SLUG"
+ echo "CI_REF_NAME=$CI_REF_NAME"
+ echo "CI_REF_NAME_SLUG=$CI_REF_NAME_SLUG"
+ echo "CI_REF=$CI_REF"
+ echo "CI_HEAD_REF_SLUG=$CI_HEAD_REF_SLUG"
+ echo "CI_HEAD_REF=$CI_HEAD_REF"
+ echo "CI_BASE_REF_SLUG=$CI_BASE_REF_SLUG"
+ echo "CI_BASE_REF=$CI_BASE_REF"
+ echo "CI_SHA_SHORT=$CI_SHA_SHORT"
+ echo "CI_SHA=$CI_SHA"
+ echo "CI_ACTOR=$CI_ACTOR"
- name: Print environment variables exposed by GitHub
run: |
echo "GITHUB_ACTOR=$GITHUB_ACTOR"
@@ -41,22 +47,28 @@ jobs:
name: Windows Demo
runs-on: windows-latest
steps:
- - uses: FranzDiebold/github-env-vars-action@v1.3.0
+ - uses: FranzDiebold/github-env-vars-action@v2
- name: Print environment variables exposed by this action
run: |
- echo "GITHUB_REPOSITORY_SLUG=$Env:GITHUB_REPOSITORY_SLUG"
- echo "GITHUB_REPOSITORY_OWNER=$Env:GITHUB_REPOSITORY_OWNER"
- echo "GITHUB_REPOSITORY_OWNER_SLUG=$Env:GITHUB_REPOSITORY_OWNER_SLUG"
- echo "GITHUB_REPOSITORY_NAME=$Env:GITHUB_REPOSITORY_NAME"
- echo "GITHUB_REPOSITORY_NAME_SLUG=$Env:GITHUB_REPOSITORY_NAME_SLUG"
- echo "GITHUB_REF_SLUG=$Env:GITHUB_REF_SLUG"
- echo "GITHUB_BRANCH_NAME=$Env:GITHUB_BRANCH_NAME"
- echo "GITHUB_BRANCH_NAME_SLUG=$Env:GITHUB_BRANCH_NAME_SLUG"
- echo "GITHUB_REF_NAME=$Env:GITHUB_REF_NAME"
- echo "GITHUB_REF_NAME_SLUG=$Env:GITHUB_REF_NAME_SLUG"
- echo "GITHUB_HEAD_REF_SLUG=$Env:GITHUB_HEAD_REF_SLUG"
- echo "GITHUB_BASE_REF_SLUG=$Env:GITHUB_BASE_REF_SLUG"
- echo "GITHUB_SHA_SHORT=$Env:GITHUB_SHA_SHORT"
+ echo "CI_REPOSITORY_SLUG=$Env:CI_REPOSITORY_SLUG"
+ echo "CI_REPOSITORY_OWNER=$Env:CI_REPOSITORY_OWNER"
+ echo "CI_REPOSITORY_OWNER_SLUG=$Env:CI_REPOSITORY_OWNER_SLUG"
+ echo "CI_REPOSITORY_NAME=$Env:CI_REPOSITORY_NAME"
+ echo "CI_REPOSITORY_NAME_SLUG=$Env:CI_REPOSITORY_NAME_SLUG"
+ echo "CI_REPOSITORY=$Env:CI_REPOSITORY"
+ echo "CI_REF_SLUG=$Env:CI_REF_SLUG"
+ echo "CI_ACTION_REF_NAME=$Env:CI_ACTION_REF_NAME"
+ echo "CI_ACTION_REF_NAME_SLUG=$Env:CI_ACTION_REF_NAME_SLUG"
+ echo "CI_REF_NAME=$Env:CI_REF_NAME"
+ echo "CI_REF_NAME_SLUG=$Env:CI_REF_NAME_SLUG"
+ echo "CI_REF=$Env:CI_REF"
+ echo "CI_HEAD_REF_SLUG=$Env:CI_HEAD_REF_SLUG"
+ echo "CI_HEAD_REF=$Env:CI_HEAD_REF"
+ echo "CI_BASE_REF_SLUG=$Env:CI_BASE_REF_SLUG"
+ echo "CI_BASE_REF=$Env:CI_BASE_REF"
+ echo "CI_SHA_SHORT=$Env:CI_SHA_SHORT"
+ echo "CI_SHA=$Env:CI_SHA"
+ echo "CI_ACTOR=$Env:CI_ACTOR"
- name: Print environment variables exposed by GitHub
run: |
echo "GITHUB_ACTOR=$Env:GITHUB_ACTOR"
@@ -75,22 +87,28 @@ jobs:
name: macOS Demo
runs-on: macos-latest
steps:
- - uses: FranzDiebold/github-env-vars-action@v1.3.0
+ - uses: FranzDiebold/github-env-vars-action@v2
- name: Print environment variables exposed by this action
run: |
- echo "GITHUB_REPOSITORY_SLUG=$GITHUB_REPOSITORY_SLUG"
- echo "GITHUB_REPOSITORY_OWNER=$GITHUB_REPOSITORY_OWNER"
- echo "GITHUB_REPOSITORY_OWNER_SLUG=$GITHUB_REPOSITORY_OWNER_SLUG"
- echo "GITHUB_REPOSITORY_NAME=$GITHUB_REPOSITORY_NAME"
- echo "GITHUB_REPOSITORY_NAME_SLUG=$GITHUB_REPOSITORY_NAME_SLUG"
- echo "GITHUB_REF_SLUG=$GITHUB_REF_SLUG"
- echo "GITHUB_BRANCH_NAME=$GITHUB_BRANCH_NAME"
- echo "GITHUB_BRANCH_NAME_SLUG=$GITHUB_BRANCH_NAME_SLUG"
- echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
- echo "GITHUB_REF_NAME_SLUG=$GITHUB_REF_NAME_SLUG"
- echo "GITHUB_HEAD_REF_SLUG=$GITHUB_HEAD_REF_SLUG"
- echo "GITHUB_BASE_REF_SLUG=$GITHUB_BASE_REF_SLUG"
- echo "GITHUB_SHA_SHORT=$GITHUB_SHA_SHORT"
+ echo "CI_REPOSITORY_SLUG=$CI_REPOSITORY_SLUG"
+ echo "CI_REPOSITORY_OWNER=$CI_REPOSITORY_OWNER"
+ echo "CI_REPOSITORY_OWNER_SLUG=$CI_REPOSITORY_OWNER_SLUG"
+ echo "CI_REPOSITORY_NAME=$CI_REPOSITORY_NAME"
+ echo "CI_REPOSITORY_NAME_SLUG=$CI_REPOSITORY_NAME_SLUG"
+ echo "CI_REPOSITORY=$CI_REPOSITORY"
+ echo "CI_REF_SLUG=$CI_REF_SLUG"
+ echo "CI_ACTION_REF_NAME=$CI_ACTION_REF_NAME"
+ echo "CI_ACTION_REF_NAME_SLUG=$CI_ACTION_REF_NAME_SLUG"
+ echo "CI_REF_NAME=$CI_REF_NAME"
+ echo "CI_REF_NAME_SLUG=$CI_REF_NAME_SLUG"
+ echo "CI_REF=$CI_REF"
+ echo "CI_HEAD_REF_SLUG=$CI_HEAD_REF_SLUG"
+ echo "CI_HEAD_REF=$CI_HEAD_REF"
+ echo "CI_BASE_REF_SLUG=$CI_BASE_REF_SLUG"
+ echo "CI_BASE_REF=$CI_BASE_REF"
+ echo "CI_SHA_SHORT=$CI_SHA_SHORT"
+ echo "CI_SHA=$CI_SHA"
+ echo "CI_ACTOR=$CI_ACTOR"
- name: Print environment variables exposed by GitHub
run: |
echo "GITHUB_ACTOR=$GITHUB_ACTOR"
diff --git a/README.md b/README.md
index b898e20..3fc221c 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: v1.3.0](https://img.shields.io/badge/Version-v1.3.0-brightgreen)](https://github.com/FranzDiebold/github-env-vars-action/releases/tag/v1.3.0)
+[![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)
[![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)
@@ -10,21 +10,27 @@ A [GitHub Action](https://github.com/features/actions) to expose useful environm
### Environment Variables exposed by **this Action**
-| Environment Variable Name | Description | Example value |
-|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------|
-| `GITHUB_REPOSITORY_SLUG` | The slug of the owner and repository name (i.e. slug of `FranzDiebold/github-env-vars-action`). | `franzdiebold-github-env-vars-action` |
-| `GITHUB_REPOSITORY_OWNER` | The owner of the repository. | `FranzDiebold` |
-| `GITHUB_REPOSITORY_OWNER_SLUG` | The slug of the owner of the repository. | `franzdiebold` |
-| `GITHUB_REPOSITORY_NAME` | The name of the repository. | `github-env-vars-action` |
-| `GITHUB_REPOSITORY_NAME_SLUG` | The slug of the name of the repository. | `github-env-vars-action` |
-| `GITHUB_REF_SLUG` | The slug of the branch or tag *ref* that triggered the workflow (i.e. slug of `refs/heads/feat/feature-branch-1`).
If neither a branch or tag is available for the event type, the variable will not exist. | `refs-heads-feat-feature-branch-1` |
-| `GITHUB_BRANCH_NAME` | The branch *name* that triggered the workflow. For pull requests it is the *head* branch name. | `feat/feature-branch-1` |
-| `GITHUB_BRANCH_NAME_SLUG` | The slug of the branch *name* that triggered the workflow. For pull requests it is the slug of the *head* branch name. | `feat-feature-branch-1` |
-| `GITHUB_REF_NAME` | The branch or tag *name* that triggered the workflow.
If neither a branch or tag is available for the event type, the variable will not exist. | `feat/feature-branch-1` |
-| `GITHUB_REF_NAME_SLUG` | The slug of the branch or tag *name* that triggered the workflow.
If neither a branch or tag is available for the event type, the variable will not exist. | `feat-feature-branch-1` |
-| `GITHUB_HEAD_REF_SLUG` | The slug of the head branch *name*.
Only set for event type *pull request* or forked repositories. | `feat-feature-branch-1` |
-| `GITHUB_BASE_REF_SLUG` | The slug of the base branch *name*.
Only set for event type *pull request* or forked repositories. | `main` |
-| `GITHUB_SHA_SHORT` | The shortened commit SHA (8 characters) that triggered the workflow. | `ffac537e` |
+| Environment Variable Name | Description | Example value |
+|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|
+| `CI_REPOSITORY_SLUG` | The slug of the owner and repository name (i.e. slug of `FranzDiebold/github-env-vars-action`). | `franzdiebold-github-env-vars-action` |
+| `CI_REPOSITORY_OWNER` | The owner of the repository. | `FranzDiebold` |
+| `CI_REPOSITORY_OWNER_SLUG` | The slug of the owner of the repository. | `franzdiebold` |
+| `CI_REPOSITORY_NAME` | The name of the repository. | `github-env-vars-action` |
+| `CI_REPOSITORY_NAME_SLUG` | The slug of the name of the repository. | `github-env-vars-action` |
+| `CI_REPOSITORY` | The owner and repository name. Copy of `GITHUB_REPOSITORY` - for reasons of completeness. | `FranzDiebold/github-env-vars-action` |
+| `CI_REF_SLUG` | The slug of the branch or tag *ref* that triggered the workflow (i.e. slug of `refs/heads/feat/feature-branch-1`).
If neither a branch or tag is available for the event type, the variable will not exist. | `refs-heads-feat-feature-branch-1` |
+| `CI_ACTION_REF_NAME` | The branch or tag *name* that triggered the workflow. For pull requests it is the *head* branch name. | `feat/feature-branch-1` |
+| `CI_ACTION_REF_NAME_SLUG` | The slug of the branch or tag *name* that triggered the workflow. For pull requests it is the slug of the *head* branch name. | `feat-feature-branch-1` |
+| `CI_REF_NAME` | The branch or tag *name* that triggered the workflow.
If neither a branch or tag is available for the event type, the variable will not exist. | `feat/feature-branch-1` |
+| `CI_REF_NAME_SLUG` | The slug of the branch or tag *name* that triggered the workflow.
If neither a branch or tag is available for the event type, the variable will not exist. | `feat-feature-branch-1` |
+| `CI_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. Copy of `GITHUB_REF` - for reasons of completeness. | `refs/heads/feat/feature-branch-1` |
+| `CI_HEAD_REF_SLUG` | The slug of the head branch *name*.
Only set for event type *pull request* or forked repositories. | `feat-feature-branch-1` |
+| `CI_HEAD_REF` | Only set for forked repositories / pull request. The branch of the head repository / the head branch name. Copy of `GITHUB_HEAD_REF` - for reasons of completeness. | `feat/feature-branch-1` |
+| `CI_BASE_REF_SLUG` | The slug of the base branch *name*.
Only set for event type *pull request* or forked repositories. | `main` |
+| `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_ACTOR` | The name of the person or app that initiated the workflow. Copy of `GITHUB_ACTOR` - for reasons of completeness. | `octocat` |
> The [slugified](https://en.wikipedia.org/wiki/Clean_URL#Slug) values are designed to be used in a URL.
@@ -45,22 +51,28 @@ For a full list of default environment variables exposed by GitHub see [https://
```yaml
steps:
- - uses: FranzDiebold/github-env-vars-action@v1.3.0
+ - uses: FranzDiebold/github-env-vars-action@v2
- name: Print environment variables
run: |
- echo "GITHUB_REPOSITORY_SLUG=$GITHUB_REPOSITORY_SLUG"
- echo "GITHUB_REPOSITORY_OWNER=$GITHUB_REPOSITORY_OWNER"
- echo "GITHUB_REPOSITORY_OWNER_SLUG=$GITHUB_REPOSITORY_OWNER_SLUG"
- echo "GITHUB_REPOSITORY_NAME=$GITHUB_REPOSITORY_NAME"
- echo "GITHUB_REPOSITORY_NAME_SLUG=$GITHUB_REPOSITORY_NAME_SLUG"
- echo "GITHUB_REF_SLUG=$GITHUB_REF_SLUG"
- echo "GITHUB_BRANCH_NAME=$GITHUB_BRANCH_NAME"
- echo "GITHUB_BRANCH_NAME_SLUG=$GITHUB_BRANCH_NAME_SLUG"
- echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
- echo "GITHUB_REF_NAME_SLUG=$GITHUB_REF_NAME_SLUG"
- echo "GITHUB_HEAD_REF_SLUG=$GITHUB_HEAD_REF_SLUG"
- echo "GITHUB_BASE_REF_SLUG=$GITHUB_BASE_REF_SLUG"
- echo "GITHUB_SHA_SHORT=$GITHUB_SHA_SHORT"
+ echo "CI_REPOSITORY_SLUG=$CI_REPOSITORY_SLUG"
+ echo "CI_REPOSITORY_OWNER=$CI_REPOSITORY_OWNER"
+ echo "CI_REPOSITORY_OWNER_SLUG=$CI_REPOSITORY_OWNER_SLUG"
+ echo "CI_REPOSITORY_NAME=$CI_REPOSITORY_NAME"
+ echo "CI_REPOSITORY_NAME_SLUG=$CI_REPOSITORY_NAME_SLUG"
+ echo "CI_REPOSITORY=$CI_REPOSITORY"
+ echo "CI_REF_SLUG=$CI_REF_SLUG"
+ echo "CI_ACTION_REF_NAME=$CI_ACTION_REF_NAME"
+ echo "CI_ACTION_REF_NAME_SLUG=$CI_ACTION_REF_NAME_SLUG"
+ echo "CI_REF_NAME=$CI_REF_NAME"
+ echo "CI_REF_NAME_SLUG=$CI_REF_NAME_SLUG"
+ echo "CI_REF=$CI_REF"
+ echo "CI_HEAD_REF_SLUG=$CI_HEAD_REF_SLUG"
+ echo "CI_HEAD_REF=$CI_HEAD_REF"
+ echo "CI_BASE_REF_SLUG=$CI_BASE_REF_SLUG"
+ echo "CI_BASE_REF=$CI_BASE_REF"
+ echo "CI_SHA_SHORT=$CI_SHA_SHORT"
+ echo "CI_SHA=$CI_SHA"
+ echo "CI_ACTOR=$CI_ACTOR"
```
### Demo
diff --git a/dist/index.js b/dist/index.js
index 05aad0e..86e47cf 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -59,119 +59,139 @@ function getShaShort(fullSha) {
return fullSha ? fullSha.substring(0, 8) : null;
}
-// https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables
+// https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
+
try {
// i.e. FranzDiebold/github-env-vars-action
repository = process.env.GITHUB_REPOSITORY;
if (repository) {
- core.exportVariable('GITHUB_REPOSITORY_SLUG', slugify(repository));
- core.info(`Set GITHUB_REPOSITORY_SLUG=` +
- `${process.env.GITHUB_REPOSITORY_SLUG}`);
+ core.exportVariable('CI_REPOSITORY_SLUG', slugify(repository));
+ core.info(`Set CI_REPOSITORY_SLUG=` +
+ `${process.env.CI_REPOSITORY_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REPOSITORY" not set. ' +
- 'Cannot set "GITHUB_REPOSITORY_SLUG".');
+ 'Cannot set "CI_REPOSITORY_SLUG".');
}
repositoryOwner = getRepositoryOwner(repository);
if (repositoryOwner) {
- core.exportVariable('GITHUB_REPOSITORY_OWNER', repositoryOwner);
- core.info(`Set GITHUB_REPOSITORY_OWNER=` +
- `${process.env.GITHUB_REPOSITORY_OWNER}`);
+ core.exportVariable('CI_REPOSITORY_OWNER', repositoryOwner);
+ core.info(`Set CI_REPOSITORY_OWNER=` +
+ `${process.env.CI_REPOSITORY_OWNER}`);
- core.exportVariable('GITHUB_REPOSITORY_OWNER_SLUG',
+ core.exportVariable('CI_REPOSITORY_OWNER_SLUG',
slugify(repositoryOwner));
- core.info(`Set GITHUB_REPOSITORY_OWNER_SLUG=` +
- `${process.env.GITHUB_REPOSITORY_OWNER_SLUG}`);
+ core.info(`Set CI_REPOSITORY_OWNER_SLUG=` +
+ `${process.env.CI_REPOSITORY_OWNER_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REPOSITORY" not set. ' +
- 'Cannot set "GITHUB_REPOSITORY_OWNER" and ' +
- '"GITHUB_REPOSITORY_OWNER_SLUG".');
+ 'Cannot set "CI_REPOSITORY_OWNER" and ' +
+ '"CI_REPOSITORY_OWNER_SLUG".');
}
repositoryName = getRepositoryName(repository);
if (repositoryName) {
- core.exportVariable('GITHUB_REPOSITORY_NAME', repositoryName);
- core.info(`Set GITHUB_REPOSITORY_NAME=` +
- `${process.env.GITHUB_REPOSITORY_NAME}`);
+ core.exportVariable('CI_REPOSITORY_NAME', repositoryName);
+ core.info(`Set CI_REPOSITORY_NAME=` +
+ `${process.env.CI_REPOSITORY_NAME}`);
- core.exportVariable('GITHUB_REPOSITORY_NAME_SLUG',
+ core.exportVariable('CI_REPOSITORY_NAME_SLUG',
slugify(repositoryName));
- core.info(`Set GITHUB_REPOSITORY_NAME_SLUG=` +
- `${process.env.GITHUB_REPOSITORY_NAME_SLUG}`);
+ core.info(`Set CI_REPOSITORY_NAME_SLUG=` +
+ `${process.env.CI_REPOSITORY_NAME_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REPOSITORY" not set. ' +
- 'Cannot set "GITHUB_REPOSITORY_NAME" and ' +
- '"GITHUB_REPOSITORY_NAME_SLUG".');
+ 'Cannot set "CI_REPOSITORY_NAME" and ' +
+ '"CI_REPOSITORY_NAME_SLUG".');
}
+ core.exportVariable('CI_REPOSITORY', repository);
+ core.info(`Set CI_REPOSITORY=${process.env.CI_REPOSITORY}`);
+
// i.e. refs/heads/feat/feature-branch-1
ref = process.env.GITHUB_REF;
if (ref) {
- core.exportVariable('GITHUB_REF_SLUG', slugify(ref));
- core.info(`Set GITHUB_REF_SLUG=${process.env.GITHUB_REF_SLUG}`);
+ core.exportVariable('CI_REF_SLUG', slugify(ref));
+ core.info(`Set CI_REF_SLUG=${process.env.CI_REF_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REF" not set. ' +
- 'Cannot set "GITHUB_REF_SLUG".');
+ 'Cannot set "CI_REF_SLUG".');
}
refName = getRefName(ref);
if (refName) {
- core.exportVariable('GITHUB_REF_NAME', refName);
- core.info(`Set GITHUB_REF_NAME=${process.env.GITHUB_REF_NAME}`);
+ core.exportVariable('CI_REF_NAME', refName);
+ core.info(`Set CI_REF_NAME=${process.env.CI_REF_NAME}`);
- core.exportVariable('GITHUB_REF_NAME_SLUG', slugify(refName));
- core.info(`Set GITHUB_REF_NAME_SLUG=${process.env.GITHUB_REF_NAME_SLUG}`);
+ core.exportVariable('CI_REF_NAME_SLUG', slugify(refName));
+ core.info(`Set CI_REF_NAME_SLUG=${process.env.CI_REF_NAME_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REF" not set. ' +
- 'Cannot set "GITHUB_REF_NAME" and ' +
- '"GITHUB_REF_NAME_SLUG".');
+ 'Cannot set "CI_REF_NAME" and ' +
+ '"CI_REF_NAME_SLUG".');
}
+ core.exportVariable('CI_REF', ref);
+ core.info(`Set CI_REF=${process.env.CI_REF}`);
+
headRef = process.env.GITHUB_HEAD_REF;
branchName = headRef || refName;
if (branchName) {
- core.exportVariable('GITHUB_BRANCH_NAME', branchName);
- core.info(`Set GITHUB_BRANCH_NAME=${process.env.GITHUB_BRANCH_NAME}`);
+ core.exportVariable('CI_ACTION_REF_NAME', branchName);
+ core.info(`Set CI_ACTION_REF_NAME=${process.env.CI_ACTION_REF_NAME}`);
- core.exportVariable('GITHUB_BRANCH_NAME_SLUG', slugify(branchName));
- core.info('Set GITHUB_BRANCH_NAME_SLUG=' +
- `${process.env.GITHUB_BRANCH_NAME_SLUG}`);
+ core.exportVariable('CI_ACTION_REF_NAME_SLUG', slugify(branchName));
+ core.info('Set CI_ACTION_REF_NAME_SLUG=' +
+ `${process.env.CI_ACTION_REF_NAME_SLUG}`);
} else {
core.warning('Environment variables "GITHUB_REF" and ' +
'"GITHUB_HEAD_REF" not set. ' +
- 'Cannot set "GITHUB_BRANCH_NAME" and ' +
- '"GITHUB_BRANCH_NAME_SLUG".');
+ 'Cannot set "CI_ACTION_REF_NAME" and ' +
+ '"CI_ACTION_REF_NAME_SLUG".');
}
if (headRef) {
- core.exportVariable('GITHUB_HEAD_REF_SLUG', slugify(headRef));
- core.info(`Set GITHUB_HEAD_REF_SLUG=${process.env.GITHUB_HEAD_REF_SLUG}`);
+ core.exportVariable('CI_HEAD_REF_SLUG', slugify(headRef));
+ core.info(`Set CI_HEAD_REF_SLUG=${process.env.CI_HEAD_REF_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_HEAD_REF" not set. ' +
- 'Cannot set "GITHUB_HEAD_REF_SLUG".');
+ 'Cannot set "CI_HEAD_REF_SLUG".');
}
+ core.exportVariable('CI_HEAD_REF', headRef);
+ core.info(`Set CI_HEAD_REF=${process.env.CI_HEAD_REF}`);
+
baseRef = process.env.GITHUB_BASE_REF;
if (baseRef) {
- core.exportVariable('GITHUB_BASE_REF_SLUG', slugify(baseRef));
- core.info(`Set GITHUB_BASE_REF_SLUG=${process.env.GITHUB_BASE_REF_SLUG}`);
+ core.exportVariable('CI_BASE_REF_SLUG', slugify(baseRef));
+ core.info(`Set CI_BASE_REF_SLUG=${process.env.CI_BASE_REF_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_BASE_REF" not set. ' +
- 'Cannot set "GITHUB_BASE_REF_SLUG".');
+ 'Cannot set "CI_BASE_REF_SLUG".');
}
+ core.exportVariable('CI_BASE_REF', baseRef);
+ core.info(`Set CI_BASE_REF=${process.env.CI_BASE_REF}`);
+
// i.e. ffac537e6cbbf934b08745a378932722df287a53
- shaShort = getShaShort(process.env.GITHUB_SHA);
- if (shaShort) {
- core.exportVariable('GITHUB_SHA_SHORT', shaShort);
- core.info(`Set GITHUB_SHA_SHORT=${process.env.GITHUB_SHA_SHORT}`);
+ sha = process.env.GITHUB_SHA;
+ if (sha) {
+ core.exportVariable('CI_SHA_SHORT', getShaShort(sha));
+ core.info(`Set CI_SHA_SHORT=${process.env.CI_SHA_SHORT}`);
} else {
core.warning('Environment variable "GITHUB_SHA" not set. ' +
- 'Cannot set "GITHUB_SHA_SHORT".');
+ 'Cannot set "CI_SHA_SHORT".');
}
+
+ core.exportVariable('CI_SHA', sha);
+ core.info(`Set CI_SHA=${process.env.CI_SHA}`);
+
+ actor = process.env.GITHUB_ACTOR;
+ core.exportVariable('CI_ACTOR', actor);
+ core.info(`Set CI_ACTOR=${process.env.CI_ACTOR}`);
} catch (error) {
core.setFailed(error.message);
}
diff --git a/index.js b/index.js
index 6a2fe5c..8328eb9 100644
--- a/index.js
+++ b/index.js
@@ -52,119 +52,139 @@ function getShaShort(fullSha) {
return fullSha ? fullSha.substring(0, 8) : null;
}
-// https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables
+// https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
+
try {
// i.e. FranzDiebold/github-env-vars-action
repository = process.env.GITHUB_REPOSITORY;
if (repository) {
- core.exportVariable('GITHUB_REPOSITORY_SLUG', slugify(repository));
- core.info(`Set GITHUB_REPOSITORY_SLUG=` +
- `${process.env.GITHUB_REPOSITORY_SLUG}`);
+ core.exportVariable('CI_REPOSITORY_SLUG', slugify(repository));
+ core.info(`Set CI_REPOSITORY_SLUG=` +
+ `${process.env.CI_REPOSITORY_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REPOSITORY" not set. ' +
- 'Cannot set "GITHUB_REPOSITORY_SLUG".');
+ 'Cannot set "CI_REPOSITORY_SLUG".');
}
repositoryOwner = getRepositoryOwner(repository);
if (repositoryOwner) {
- core.exportVariable('GITHUB_REPOSITORY_OWNER', repositoryOwner);
- core.info(`Set GITHUB_REPOSITORY_OWNER=` +
- `${process.env.GITHUB_REPOSITORY_OWNER}`);
+ core.exportVariable('CI_REPOSITORY_OWNER', repositoryOwner);
+ core.info(`Set CI_REPOSITORY_OWNER=` +
+ `${process.env.CI_REPOSITORY_OWNER}`);
- core.exportVariable('GITHUB_REPOSITORY_OWNER_SLUG',
+ core.exportVariable('CI_REPOSITORY_OWNER_SLUG',
slugify(repositoryOwner));
- core.info(`Set GITHUB_REPOSITORY_OWNER_SLUG=` +
- `${process.env.GITHUB_REPOSITORY_OWNER_SLUG}`);
+ core.info(`Set CI_REPOSITORY_OWNER_SLUG=` +
+ `${process.env.CI_REPOSITORY_OWNER_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REPOSITORY" not set. ' +
- 'Cannot set "GITHUB_REPOSITORY_OWNER" and ' +
- '"GITHUB_REPOSITORY_OWNER_SLUG".');
+ 'Cannot set "CI_REPOSITORY_OWNER" and ' +
+ '"CI_REPOSITORY_OWNER_SLUG".');
}
repositoryName = getRepositoryName(repository);
if (repositoryName) {
- core.exportVariable('GITHUB_REPOSITORY_NAME', repositoryName);
- core.info(`Set GITHUB_REPOSITORY_NAME=` +
- `${process.env.GITHUB_REPOSITORY_NAME}`);
+ core.exportVariable('CI_REPOSITORY_NAME', repositoryName);
+ core.info(`Set CI_REPOSITORY_NAME=` +
+ `${process.env.CI_REPOSITORY_NAME}`);
- core.exportVariable('GITHUB_REPOSITORY_NAME_SLUG',
+ core.exportVariable('CI_REPOSITORY_NAME_SLUG',
slugify(repositoryName));
- core.info(`Set GITHUB_REPOSITORY_NAME_SLUG=` +
- `${process.env.GITHUB_REPOSITORY_NAME_SLUG}`);
+ core.info(`Set CI_REPOSITORY_NAME_SLUG=` +
+ `${process.env.CI_REPOSITORY_NAME_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REPOSITORY" not set. ' +
- 'Cannot set "GITHUB_REPOSITORY_NAME" and ' +
- '"GITHUB_REPOSITORY_NAME_SLUG".');
+ 'Cannot set "CI_REPOSITORY_NAME" and ' +
+ '"CI_REPOSITORY_NAME_SLUG".');
}
+ core.exportVariable('CI_REPOSITORY', repository);
+ core.info(`Set CI_REPOSITORY=${process.env.CI_REPOSITORY}`);
+
// i.e. refs/heads/feat/feature-branch-1
ref = process.env.GITHUB_REF;
if (ref) {
- core.exportVariable('GITHUB_REF_SLUG', slugify(ref));
- core.info(`Set GITHUB_REF_SLUG=${process.env.GITHUB_REF_SLUG}`);
+ core.exportVariable('CI_REF_SLUG', slugify(ref));
+ core.info(`Set CI_REF_SLUG=${process.env.CI_REF_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REF" not set. ' +
- 'Cannot set "GITHUB_REF_SLUG".');
+ 'Cannot set "CI_REF_SLUG".');
}
refName = getRefName(ref);
if (refName) {
- core.exportVariable('GITHUB_REF_NAME', refName);
- core.info(`Set GITHUB_REF_NAME=${process.env.GITHUB_REF_NAME}`);
+ core.exportVariable('CI_REF_NAME', refName);
+ core.info(`Set CI_REF_NAME=${process.env.CI_REF_NAME}`);
- core.exportVariable('GITHUB_REF_NAME_SLUG', slugify(refName));
- core.info(`Set GITHUB_REF_NAME_SLUG=${process.env.GITHUB_REF_NAME_SLUG}`);
+ core.exportVariable('CI_REF_NAME_SLUG', slugify(refName));
+ core.info(`Set CI_REF_NAME_SLUG=${process.env.CI_REF_NAME_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REF" not set. ' +
- 'Cannot set "GITHUB_REF_NAME" and ' +
- '"GITHUB_REF_NAME_SLUG".');
+ 'Cannot set "CI_REF_NAME" and ' +
+ '"CI_REF_NAME_SLUG".');
}
+ core.exportVariable('CI_REF', ref);
+ core.info(`Set CI_REF=${process.env.CI_REF}`);
+
headRef = process.env.GITHUB_HEAD_REF;
branchName = headRef || refName;
if (branchName) {
- core.exportVariable('GITHUB_BRANCH_NAME', branchName);
- core.info(`Set GITHUB_BRANCH_NAME=${process.env.GITHUB_BRANCH_NAME}`);
+ core.exportVariable('CI_ACTION_REF_NAME', branchName);
+ core.info(`Set CI_ACTION_REF_NAME=${process.env.CI_ACTION_REF_NAME}`);
- core.exportVariable('GITHUB_BRANCH_NAME_SLUG', slugify(branchName));
- core.info('Set GITHUB_BRANCH_NAME_SLUG=' +
- `${process.env.GITHUB_BRANCH_NAME_SLUG}`);
+ core.exportVariable('CI_ACTION_REF_NAME_SLUG', slugify(branchName));
+ core.info('Set CI_ACTION_REF_NAME_SLUG=' +
+ `${process.env.CI_ACTION_REF_NAME_SLUG}`);
} else {
core.warning('Environment variables "GITHUB_REF" and ' +
'"GITHUB_HEAD_REF" not set. ' +
- 'Cannot set "GITHUB_BRANCH_NAME" and ' +
- '"GITHUB_BRANCH_NAME_SLUG".');
+ 'Cannot set "CI_ACTION_REF_NAME" and ' +
+ '"CI_ACTION_REF_NAME_SLUG".');
}
if (headRef) {
- core.exportVariable('GITHUB_HEAD_REF_SLUG', slugify(headRef));
- core.info(`Set GITHUB_HEAD_REF_SLUG=${process.env.GITHUB_HEAD_REF_SLUG}`);
+ core.exportVariable('CI_HEAD_REF_SLUG', slugify(headRef));
+ core.info(`Set CI_HEAD_REF_SLUG=${process.env.CI_HEAD_REF_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_HEAD_REF" not set. ' +
- 'Cannot set "GITHUB_HEAD_REF_SLUG".');
+ 'Cannot set "CI_HEAD_REF_SLUG".');
}
+ core.exportVariable('CI_HEAD_REF', headRef);
+ core.info(`Set CI_HEAD_REF=${process.env.CI_HEAD_REF}`);
+
baseRef = process.env.GITHUB_BASE_REF;
if (baseRef) {
- core.exportVariable('GITHUB_BASE_REF_SLUG', slugify(baseRef));
- core.info(`Set GITHUB_BASE_REF_SLUG=${process.env.GITHUB_BASE_REF_SLUG}`);
+ core.exportVariable('CI_BASE_REF_SLUG', slugify(baseRef));
+ core.info(`Set CI_BASE_REF_SLUG=${process.env.CI_BASE_REF_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_BASE_REF" not set. ' +
- 'Cannot set "GITHUB_BASE_REF_SLUG".');
+ 'Cannot set "CI_BASE_REF_SLUG".');
}
+ core.exportVariable('CI_BASE_REF', baseRef);
+ core.info(`Set CI_BASE_REF=${process.env.CI_BASE_REF}`);
+
// i.e. ffac537e6cbbf934b08745a378932722df287a53
- shaShort = getShaShort(process.env.GITHUB_SHA);
- if (shaShort) {
- core.exportVariable('GITHUB_SHA_SHORT', shaShort);
- core.info(`Set GITHUB_SHA_SHORT=${process.env.GITHUB_SHA_SHORT}`);
+ sha = process.env.GITHUB_SHA;
+ if (sha) {
+ core.exportVariable('CI_SHA_SHORT', getShaShort(sha));
+ core.info(`Set CI_SHA_SHORT=${process.env.CI_SHA_SHORT}`);
} else {
core.warning('Environment variable "GITHUB_SHA" not set. ' +
- 'Cannot set "GITHUB_SHA_SHORT".');
+ 'Cannot set "CI_SHA_SHORT".');
}
+
+ core.exportVariable('CI_SHA', sha);
+ core.info(`Set CI_SHA=${process.env.CI_SHA}`);
+
+ actor = process.env.GITHUB_ACTOR;
+ core.exportVariable('CI_ACTOR', actor);
+ core.info(`Set CI_ACTOR=${process.env.CI_ACTOR}`);
} catch (error) {
core.setFailed(error.message);
}