mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-06-10 16:43:09 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d2c65418d | ||
|
|
f536765da4 | ||
|
|
72cfc4cb1f | ||
|
|
d678898ce5 | ||
|
|
f527ed6e85 |
@@ -1,6 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "github-actions"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
dist/
|
|
||||||
lib/
|
|
||||||
node_modules/
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
{
|
|
||||||
"plugins": ["jest", "@typescript-eslint"],
|
|
||||||
"extends": ["plugin:github/recommended"],
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 9,
|
|
||||||
"sourceType": "module",
|
|
||||||
"project": "./tsconfig.json"
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"eslint-comments/no-use": "off",
|
|
||||||
"import/no-namespace": "off",
|
|
||||||
"no-unused-vars": "off",
|
|
||||||
"@typescript-eslint/no-unused-vars": "error",
|
|
||||||
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
|
|
||||||
"@typescript-eslint/no-require-imports": "error",
|
|
||||||
"@typescript-eslint/array-type": "error",
|
|
||||||
"@typescript-eslint/await-thenable": "error",
|
|
||||||
"@typescript-eslint/ban-ts-comment": "error",
|
|
||||||
"camelcase": "off",
|
|
||||||
"@typescript-eslint/consistent-type-assertions": "error",
|
|
||||||
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
|
|
||||||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
|
||||||
"@typescript-eslint/no-array-constructor": "error",
|
|
||||||
"@typescript-eslint/no-empty-interface": "error",
|
|
||||||
"@typescript-eslint/no-explicit-any": "error",
|
|
||||||
"@typescript-eslint/no-extraneous-class": "error",
|
|
||||||
"@typescript-eslint/no-for-in-array": "error",
|
|
||||||
"@typescript-eslint/no-inferrable-types": "error",
|
|
||||||
"@typescript-eslint/no-misused-new": "error",
|
|
||||||
"@typescript-eslint/no-namespace": "error",
|
|
||||||
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
||||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
||||||
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
||||||
"@typescript-eslint/no-useless-constructor": "error",
|
|
||||||
"@typescript-eslint/no-var-requires": "error",
|
|
||||||
"@typescript-eslint/prefer-for-of": "warn",
|
|
||||||
"@typescript-eslint/prefer-function-type": "warn",
|
|
||||||
"@typescript-eslint/prefer-includes": "error",
|
|
||||||
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
|
||||||
"@typescript-eslint/promise-function-async": "error",
|
|
||||||
"@typescript-eslint/require-array-sort-compare": "error",
|
|
||||||
"@typescript-eslint/restrict-plus-operands": "error",
|
|
||||||
"semi": "off",
|
|
||||||
"@typescript-eslint/semi": ["error", "never"],
|
|
||||||
"@typescript-eslint/type-annotation-spacing": "error",
|
|
||||||
"@typescript-eslint/unbound-method": "error"
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
"es6": true,
|
|
||||||
"jest/globals": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
72
.github/workflows/build.yml
vendored
72
.github/workflows/build.yml
vendored
@@ -1,72 +0,0 @@
|
|||||||
name: Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- v3.x
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- run: |
|
|
||||||
npm ci
|
|
||||||
- run: |
|
|
||||||
npm run all
|
|
||||||
- uses: cycjimmy/semantic-release-action@v2
|
|
||||||
with:
|
|
||||||
semantic_version: 17.0.7
|
|
||||||
branches: |
|
|
||||||
[
|
|
||||||
'v2.x',
|
|
||||||
'v3.x'
|
|
||||||
]
|
|
||||||
extra_plugins: |
|
|
||||||
@semantic-release/changelog@5.0.1
|
|
||||||
@semantic-release/git@9.0.0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
test: # make sure the action works on a clean machine without building
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os:
|
|
||||||
- ubuntu-latest
|
|
||||||
- macos-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: ./
|
|
||||||
- run: |
|
|
||||||
echo $GITHUB_REPOSITORY_SLUG
|
|
||||||
echo $GITHUB_REPOSITORY_SLUG_URL
|
|
||||||
echo $GITHUB_REF_SLUG
|
|
||||||
echo $GITHUB_HEAD_REF_SLUG
|
|
||||||
echo $GITHUB_BASE_REF_SLUG
|
|
||||||
echo $GITHUB_EVENT_REF_SLUG
|
|
||||||
echo $GITHUB_REF_SLUG_URL
|
|
||||||
echo $GITHUB_HEAD_REF_SLUG_URL
|
|
||||||
echo $GITHUB_BASE_REF_SLUG_URL
|
|
||||||
echo $GITHUB_EVENT_REF_SLUG_URL
|
|
||||||
echo $GITHUB_SHA_SHORT
|
|
||||||
echo $GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT
|
|
||||||
|
|
||||||
test-win:
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: ./
|
|
||||||
- run: |
|
|
||||||
echo $env:GITHUB_REPOSITORY_SLUG
|
|
||||||
echo $env:GITHUB_REPOSITORY_SLUG_URL
|
|
||||||
echo $env:GITHUB_REF_SLUG
|
|
||||||
echo $env:GITHUB_HEAD_REF_SLUG
|
|
||||||
echo $env:GITHUB_BASE_REF_SLUG
|
|
||||||
echo $env:GITHUB_EVENT_REF_SLUG
|
|
||||||
echo $env:GITHUB_REF_SLUG_URL
|
|
||||||
echo $env:GITHUB_HEAD_REF_SLUG_URL
|
|
||||||
echo $env:GITHUB_BASE_REF_SLUG_URL
|
|
||||||
echo $env:GITHUB_EVENT_REF_SLUG_URL
|
|
||||||
echo $env:GITHUB_SHA_SHORT
|
|
||||||
echo $env:GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT
|
|
||||||
45
.github/workflows/ci.yml
vendored
Normal file
45
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
name: Build
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: docker://ffurrer/bats:latest
|
||||||
|
with:
|
||||||
|
args: "--recursive ."
|
||||||
|
- uses: cycjimmy/semantic-release-action@v2
|
||||||
|
with:
|
||||||
|
semantic_version: 17.0.7
|
||||||
|
branches: |
|
||||||
|
[
|
||||||
|
'v1.1.x',
|
||||||
|
'v2.x'
|
||||||
|
]
|
||||||
|
extra_plugins: |
|
||||||
|
@semantic-release/changelog@5.0.1
|
||||||
|
@semantic-release/git@9.0.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ./
|
||||||
|
- name: Output
|
||||||
|
run: |
|
||||||
|
echo "Slug variables"
|
||||||
|
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
|
||||||
|
echo " ref : ${{ env.GITHUB_REF_SLUG }}"
|
||||||
|
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
||||||
|
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
||||||
|
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
||||||
|
echo "Slug URL variables"
|
||||||
|
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
||||||
|
echo " ref : ${{ env.GITHUB_REF_SLUG_URL }}"
|
||||||
|
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
|
||||||
|
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
|
||||||
|
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
|
||||||
|
echo "Short SHA variables"
|
||||||
|
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||||
34
.github/workflows/codeql-analysis.yml
vendored
34
.github/workflows/codeql-analysis.yml
vendored
@@ -1,34 +0,0 @@
|
|||||||
name: "CodeQL"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ v3.x, v*.x ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ v3.x ]
|
|
||||||
schedule:
|
|
||||||
- cron: '0 6 * * 1'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
analyze:
|
|
||||||
name: Analyze
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
language: [ 'javascript' ]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@v1
|
|
||||||
with:
|
|
||||||
languages: ${{ matrix.language }}
|
|
||||||
|
|
||||||
- name: Autobuild
|
|
||||||
uses: github/codeql-action/autobuild@v1
|
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
|
||||||
uses: github/codeql-action/analyze@v1
|
|
||||||
29
.github/workflows/linter.yml
vendored
29
.github/workflows/linter.yml
vendored
@@ -1,29 +0,0 @@
|
|||||||
name: Lint
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- v3.x
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: Lint
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout Code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Lint Code Base
|
|
||||||
uses: github/super-linter@v3
|
|
||||||
env:
|
|
||||||
VALIDATE_ALL_CODEBASE: false
|
|
||||||
LINTER_RULES_PATH: .
|
|
||||||
JAVASCRIPT_ES_CONFIG_FILE: .eslintrc.json
|
|
||||||
JAVASCRIPT_DEFAULT_STYLE: prettier
|
|
||||||
DEFAULT_BRANCH: v3.x
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
FILTER_REGEX_INCLUDE: .*src/.*
|
|
||||||
100
.gitignore
vendored
100
.gitignore
vendored
@@ -1,99 +1 @@
|
|||||||
# Dependency directory
|
node_modules/
|
||||||
node_modules
|
|
||||||
|
|
||||||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
*.lcov
|
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
jspm_packages/
|
|
||||||
|
|
||||||
# TypeScript v1 declaration files
|
|
||||||
typings/
|
|
||||||
|
|
||||||
# TypeScript cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# Output of 'npm pack'
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# Yarn Integrity file
|
|
||||||
.yarn-integrity
|
|
||||||
|
|
||||||
# dotenv environment variables file
|
|
||||||
.env
|
|
||||||
.env.test
|
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# next.js build output
|
|
||||||
.next
|
|
||||||
|
|
||||||
# nuxt.js build output
|
|
||||||
.nuxt
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# OS metadata
|
|
||||||
.DS_Store
|
|
||||||
Thumbs.db
|
|
||||||
|
|
||||||
# Ignore built ts files
|
|
||||||
__tests__/runner/*
|
|
||||||
lib/**/*
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
dist/
|
|
||||||
lib/
|
|
||||||
node_modules/
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"printWidth": 80,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"semi": false,
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "none",
|
|
||||||
"bracketSpacing": false,
|
|
||||||
"arrowParens": "avoid"
|
|
||||||
}
|
|
||||||
27
CHANGELOG.md
27
CHANGELOG.md
@@ -1,35 +1,16 @@
|
|||||||
# [3.2.0](http://github.com/rlespinasse/github-slug-action/compare/3.1.0...3.2.0) (2021-01-12)
|
# [2.2.0](http://github.com/rlespinasse/github-slug-action/compare/2.1.1...2.2.0) (2021-04-05)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* expose GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT ([5b9fe60](http://github.com/rlespinasse/github-slug-action/commit/5b9fe6015d2facc71c81d53bf3b08f04e0f3f743))
|
* add version warning ([f536765](http://github.com/rlespinasse/github-slug-action/commit/f536765da448783f587c88e2c69f8f65b4e06541))
|
||||||
|
|
||||||
# [3.1.0](http://github.com/rlespinasse/github-slug-action/compare/3.0.0...3.1.0) (2020-11-01)
|
## [2.1.1](http://github.com/rlespinasse/github-slug-action/compare/2.1.0...2.1.1) (2020-10-07)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* **action:** improve marketplace information ([3cddc4f](http://github.com/rlespinasse/github-slug-action/commit/3cddc4f12d7a6fdbb8b1221dc02a2c64670e54bf))
|
|
||||||
|
|
||||||
# [3.0.0](http://github.com/rlespinasse/github-slug-action/compare/2.1.0...3.0.0) (2020-10-26)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* upgrade actions core due to CVE fix ([d0549c1](http://github.com/rlespinasse/github-slug-action/commit/d0549c1f85ab9567b439f9d660b01ce1142b9fbe))
|
* remove set-env due to CVE fix ([d678898](http://github.com/rlespinasse/github-slug-action/commit/d678898ce55139d0005c35618747506fbeb2d1ed))
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add support for windows and macos jobs ([13c2f38](http://github.com/rlespinasse/github-slug-action/commit/13c2f38dad5f32529f37c25736412b1e4cf687fe))
|
|
||||||
|
|
||||||
|
|
||||||
### BREAKING CHANGES
|
|
||||||
|
|
||||||
* The action implementation move from container action to node.js action
|
|
||||||
|
|
||||||
Co-authored-by: Romain Lespinasse <romain.lespinasse@gmail.com>
|
|
||||||
|
|
||||||
# [2.1.0](http://github.com/rlespinasse/github-slug-action/compare/2.0.0...2.1.0) (2020-07-28)
|
# [2.1.0](http://github.com/rlespinasse/github-slug-action/compare/2.0.0...2.1.0) (2020-07-28)
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
# How to contribute to GitHub Slug Action
|
|
||||||
|
|
||||||
## Did you find a bug
|
|
||||||
|
|
||||||
* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead to refer to our [security policy][1].
|
|
||||||
|
|
||||||
* **Ensure the bug was not already reported** by searching on GitHub under [Issues][2].
|
|
||||||
|
|
||||||
* If you're unable to find an open issue addressing the problem, [open a 'Bug' issue][4].
|
|
||||||
Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
|
|
||||||
|
|
||||||
## Did you write a patch that fixes a bug
|
|
||||||
|
|
||||||
* Open a new GitHub pull request with the patch.
|
|
||||||
|
|
||||||
* Ensure the PR description clearly describes the problem and solution.
|
|
||||||
Include the relevant issue number if applicable.
|
|
||||||
|
|
||||||
## Do you intend to add a new feature or change an existing one
|
|
||||||
|
|
||||||
* Suggest your change by [opening a 'Feature request' issue][5] and start writing code.
|
|
||||||
|
|
||||||
## Do you have questions about the source code
|
|
||||||
|
|
||||||
* [open an issue][3] with your question.
|
|
||||||
|
|
||||||
Thanks!
|
|
||||||
|
|
||||||
[1]: https://github.com/rlespinasse/github-slug-action/security/policy
|
|
||||||
[2]: https://github.com/rlespinasse/github-slug-action/issues
|
|
||||||
[3]: https://github.com/rlespinasse/github-slug-action/issues/new
|
|
||||||
[4]: https://github.com/rlespinasse/github-slug-action/issues/new?assignees=&labels=bug&template=bug_report.md&title=
|
|
||||||
[5]: https://github.com/rlespinasse/github-slug-action/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# Developers guide
|
|
||||||
|
|
||||||
Install the dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
Build the typescript and package it for distribution
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run build && npm run package
|
|
||||||
```
|
|
||||||
|
|
||||||
Run the tests
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ npm test
|
|
||||||
|
|
||||||
PASS ./index.test.js
|
|
||||||
✓ throws invalid number (3ms)
|
|
||||||
✓ wait 500 ms (504ms)
|
|
||||||
✓ test runs (95ms)
|
|
||||||
|
|
||||||
...
|
|
||||||
```
|
|
||||||
4
Dockerfile
Normal file
4
Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM alpine:3.10
|
||||||
|
RUN apk add --no-cache jq
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
84
README.md
84
README.md
@@ -1,11 +1,9 @@
|
|||||||
# GitHub Slug action
|
# GitHub Slug action
|
||||||
|
|
||||||
[![Actions Status][1]][2]
|
[![Actions Status][1]][2]
|
||||||
![GitHub Super-Linter][13]
|
|
||||||
[![Public workflows that use this action.][8]][9]
|
[![Public workflows that use this action.][8]][9]
|
||||||
[![Licence][11]][12]
|
|
||||||
|
|
||||||
This GitHub Action will expose the slug value of all [GitHub environment variables][10] inside your GitHub workflow.
|
This action slug and expose some github variables.
|
||||||
|
|
||||||
`Slug` a variable will
|
`Slug` a variable will
|
||||||
|
|
||||||
@@ -19,35 +17,32 @@ Others `Slug`-ish commands are available:
|
|||||||
- `Slug URL` a variable will be like the `slug` variable but the `.` character will also be replaced by `-`
|
- `Slug URL` a variable will be like the `slug` variable but the `.` character will also be replaced by `-`
|
||||||
- `Short SHA` a variable will limit the string size to 8 characters
|
- `Short SHA` a variable will limit the string size to 8 characters
|
||||||
|
|
||||||
## Exposed GitHub environment variables
|
## Exposed environment variables
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Inject slug/short variables
|
- name: Inject slug/short variables
|
||||||
uses: rlespinasse/github-slug-action@v3.x
|
uses: rlespinasse/github-slug-action@v2.x
|
||||||
|
|
||||||
- name: Print slug/short variables
|
- name: Print slug/short variables
|
||||||
run: |
|
run: |
|
||||||
echo "Slug variables"
|
echo "Slug variables"
|
||||||
echo " ref : ${{ env.GITHUB_REF_SLUG }}"
|
echo " ref : ${{ env.GITHUB_REF_SLUG }}"
|
||||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
||||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
||||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
||||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
|
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
|
||||||
echo "Slug URL variables"
|
echo "Slug URL variables"
|
||||||
echo " ref : ${{ env.GITHUB_REF_SLUG_URL }}"
|
echo " ref : ${{ env.GITHUB_REF_SLUG_URL }}"
|
||||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
|
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
|
||||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
|
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
|
||||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
|
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
|
||||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
||||||
echo "Short SHA variables"
|
echo "Short SHA variables"
|
||||||
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||||
echo " pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Read [default environment variables][3] page for more information.
|
Read [default environment variables][3] page for more information.
|
||||||
|
|
||||||
**TIP:** Use [Dependabot][14] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
|
||||||
|
|
||||||
### GITHUB_REF_SLUG / GITHUB_REF_SLUG_URL
|
### GITHUB_REF_SLUG / GITHUB_REF_SLUG_URL
|
||||||
|
|
||||||
Slug the environment variable **GITHUB_REF**
|
Slug the environment variable **GITHUB_REF**
|
||||||
@@ -99,15 +94,6 @@ The commit SHA that triggered the workflow
|
|||||||
| ---------------------------------------- | ---------------- |
|
| ---------------------------------------- | ---------------- |
|
||||||
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
||||||
|
|
||||||
### GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT
|
|
||||||
|
|
||||||
Short the value of `github.event.pull_request.head.sha` that represents the last commit
|
|
||||||
used for triggering an action for a pull request.
|
|
||||||
|
|
||||||
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
|
|
||||||
| ---------------------------------------- | ---------------------------------------- |
|
|
||||||
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
|
||||||
|
|
||||||
### Use slug variable in an URL
|
### Use slug variable in an URL
|
||||||
|
|
||||||
In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>\_SLUG** as subdomain to be compliant.
|
In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>\_SLUG** as subdomain to be compliant.
|
||||||
@@ -117,43 +103,43 @@ In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>\_SLUG
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Inject slug/short variables
|
- name: Inject slug/short variables
|
||||||
uses: rlespinasse/github-slug-action@v3.x
|
uses: rlespinasse/github-slug-action@v2.x
|
||||||
|
|
||||||
- name: Deploy dummy application using slug in the 'subdomain' part
|
- name: Deploy dummy application using slug in the 'subdomain' part
|
||||||
run: |
|
run: |
|
||||||
./deploy-application.sh --url "https://${{ env.<GITHUB_VARIABLE>_SLUG_URL }}.staging.app.mycompany.com"
|
./deploy-application.sh --url "https://${{ env.<GITHUB_VARIABLE>_SLUG_URL }}.staging.app.mycompagny.com"
|
||||||
|
|
||||||
- name: Deploy dummy application using slug in the 'resource path' part
|
- name: Deploy dummy application using slug in the 'resource path' part
|
||||||
run: |
|
run: |
|
||||||
./deploy-application.sh --url "https://staging.app.mycompany.com/${{ env.<GITHUB_VARIABLE>_SLUG }}"
|
./deploy-application.sh --url "https://staging.app.mycompagny.com/${{ env.<GITHUB_VARIABLE>_SLUG }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contribute
|
|
||||||
|
|
||||||
Follow [Developers guide](DEVELOPERS.md)
|
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### Missing master branch
|
### Missing master branch
|
||||||
|
|
||||||
If your workflow fail on the `Set up job` task with this kind of log :
|
If your workflow fail on the `Set up job` task with this kind of log :
|
||||||
|
|
||||||
```text
|
```
|
||||||
Download action repository 'rlespinasse/github-slug-action@master'
|
Download action repository 'rlespinasse/github-slug-action@master'
|
||||||
##[error]An action could not be found at the URI 'https://api.github.com/repos/rlespinasse/github-slug-action/tarball/master'
|
##[error]An action could not be found at the URI 'https://api.github.com/repos/rlespinasse/github-slug-action/tarball/master'
|
||||||
```
|
```
|
||||||
|
|
||||||
Please, use the current branch `v3.x` or a version tag (see [releases pages][6]) in order to fix your workflow.
|
Use the current branch `v2.x` or a version tag (see [releases pages][6]).
|
||||||
|
|
||||||
> The master branch don't exists anymore.
|
The master branch EOL is set on **2020-10-25** after a 6-month deprecation period (more information on the [EOL issue][7])
|
||||||
>
|
|
||||||
> The master branch EOL have been set to **2020-10-25** after a 6-month deprecation period (more information on the [EOL issue][7])
|
|
||||||
|
|
||||||
## Thanks for talking about us
|
### Can't run on Windows or Macos
|
||||||
|
|
||||||
- [Mettre en place une CI/CD Angular avec GitHub Actions & Netlify][15] (in french :fr:)
|
When using this action on Windows or Macos workflows, A `##[error]Container action is only supported on Linux` error can be see in your workflow logs.
|
||||||
- [Github Actions : enfin des pipelines accessibles aux développeurs][16] (in french :fr:)
|
Currently, this action don't support a system other than Linux due to Github Action Limitation on `Container`-based action.
|
||||||
- The next one is you. _Don't hesitate to add you to this list._
|
|
||||||
|
On the `v3.x` branch, this GitHub action have been rewrite to be able to run on Windows or Macos workflow.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Inject slug/short variables
|
||||||
|
uses: rlespinasse/github-slug-action@v3.x
|
||||||
|
```
|
||||||
|
|
||||||
[1]: https://github.com/rlespinasse/github-slug-action/workflows/Build/badge.svg
|
[1]: https://github.com/rlespinasse/github-slug-action/workflows/Build/badge.svg
|
||||||
[2]: https://github.com/rlespinasse/github-slug-action/actions
|
[2]: https://github.com/rlespinasse/github-slug-action/actions
|
||||||
@@ -163,11 +149,5 @@ Please, use the current branch `v3.x` or a version tag (see [releases pages][6])
|
|||||||
[6]: https://github.com/rlespinasse/github-slug-action/releases
|
[6]: https://github.com/rlespinasse/github-slug-action/releases
|
||||||
[7]: https://github.com/rlespinasse/github-slug-action/issues/15
|
[7]: https://github.com/rlespinasse/github-slug-action/issues/15
|
||||||
[8]: https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Drlespinasse%2Fgithub-slug-action%26badge%3Dtrue
|
[8]: https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Drlespinasse%2Fgithub-slug-action%26badge%3Dtrue
|
||||||
[9]: https://github.com/search?o=desc&q=rlespinasse/github-slug-action+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code
|
[9]: https://github.com/search?o=desc&q=rlespinasse%2Frlespinasse/github-slug-action+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code
|
||||||
[10]: https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
|
|
||||||
[11]: https://img.shields.io/github/license/rlespinasse/github-slug-action
|
|
||||||
[12]: https://github.com/rlespinasse/github-slug-action/blob/v3.x/LICENSE
|
|
||||||
[13]: https://github.com/rlespinasse/github-slug-action/workflows/Lint/badge.svg
|
|
||||||
[14]: https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot
|
|
||||||
[15]: https://esensconsulting.medium.com/mettre-en-place-une-ci-cd-angular-avec-github-actions-netlify-ca0b59b99ed8
|
|
||||||
[16]: https://www.youtube.com/watch?v=RHnTJBwcE98
|
|
||||||
|
|||||||
@@ -4,10 +4,9 @@
|
|||||||
|
|
||||||
| Version | Branch | Supported |
|
| Version | Branch | Supported |
|
||||||
|---------|--------|--------------------|
|
|---------|--------|--------------------|
|
||||||
| 3.x | v3.x | :white_check_mark: |
|
|
||||||
| 2.x | v2.x | :white_check_mark: |
|
| 2.x | v2.x | :white_check_mark: |
|
||||||
| 1.1.x | v1.1.x | :x: |
|
| 1.1.x | v1.1.x | :white_check_mark: |
|
||||||
| < 1.x | | :x: |
|
| < 1.0.x | master | :x: |
|
||||||
|
|
||||||
A GitHub repository can used one of the available branches as action inside its workflows.
|
A GitHub repository can used one of the available branches as action inside its workflows.
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
import {shortsha} from '../src/slug'
|
|
||||||
|
|
||||||
function test_short_sha(input: string, expected: string) {
|
|
||||||
let actual = shortsha(input)
|
|
||||||
expect(actual).toEqual(expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
test('short_sha: long hash', () => {
|
|
||||||
test_short_sha('a35a1a486a260cfd99c5b6f8c6034a2929ba9b3f', 'a35a1a48')
|
|
||||||
})
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
import {slug} from '../src/slug'
|
|
||||||
|
|
||||||
function test_slug(input: string, expected: string) {
|
|
||||||
let actual = slug(input)
|
|
||||||
expect(actual).toEqual(expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
test('slug: a word', () => {
|
|
||||||
test_slug('word', 'word')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug: a string', () => {
|
|
||||||
test_slug('basic-string', 'basic-string')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug: a string in camel case', () => {
|
|
||||||
test_slug('camelCase', 'camelcase')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug: a path', () => {
|
|
||||||
test_slug('path/to/something', 'path-to-something')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug: a number', () => {
|
|
||||||
test_slug('4.2', '4.2')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug: special caracter', () => {
|
|
||||||
test_slug('feat-(!è§-caracter', 'feat------caracter')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug: trailing', () => {
|
|
||||||
test_slug('-feat-trailing-', 'feat-trailing')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug: a very long string', () => {
|
|
||||||
test_slug(
|
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug: short string after trailing', () => {
|
|
||||||
test_slug(
|
|
||||||
'-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
import {slugref} from '../src/slug'
|
|
||||||
|
|
||||||
function test_slug_ref(input: string, expected: string) {
|
|
||||||
let actual = slugref(input)
|
|
||||||
expect(actual).toEqual(expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
test('slug_ref:: master branch', () => {
|
|
||||||
test_slug_ref('refs/heads/master', 'master')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: a feature branch', () => {
|
|
||||||
test_slug_ref('refs/heads/feat/new_feature', 'feat-new-feature')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: a fix branch', () => {
|
|
||||||
test_slug_ref('refs/heads/fix/issue_number', 'fix-issue-number')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: a simple tag', () => {
|
|
||||||
test_slug_ref('refs/tags/v1.0.0', 'v1.0.0')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: a complex tag', () => {
|
|
||||||
test_slug_ref('refs/tags/product@1.0.0-rc.2', 'product-1.0.0-rc.2')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: a reference with upper case letters', () => {
|
|
||||||
test_slug_ref('refs/heads/New_Awesome_Product', 'new-awesome-product')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: test trailing', () => {
|
|
||||||
test_slug_ref('refs/heads/-trailing-feat-', 'trailing-feat')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: test refs inside string', () => {
|
|
||||||
test_slug_ref('refs/heads/-refs/tags/feature/-', 'refs-tags-feature')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: a very long name', () => {
|
|
||||||
test_slug_ref(
|
|
||||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import {slugurl} from '../src/slug'
|
|
||||||
|
|
||||||
function test_slug_url(input: string, expected: string) {
|
|
||||||
let actual = slugurl(input)
|
|
||||||
expect(actual).toEqual(expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
test('slug_url: a word', () => {
|
|
||||||
test_slug_url('word', 'word')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a string', () => {
|
|
||||||
test_slug_url('basic-string', 'basic-string')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a string in camel case', () => {
|
|
||||||
test_slug_url('camelCase', 'camelcase')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a path', () => {
|
|
||||||
test_slug_url('path/to/something', 'path-to-something')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a number', () => {
|
|
||||||
test_slug_url('4.2', '4-2')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: trailing', () => {
|
|
||||||
test_slug_url('.path.to.', 'path-to')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a very long string', () => {
|
|
||||||
test_slug_url(
|
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
import {slugurlref} from '../src/slug'
|
|
||||||
|
|
||||||
function test_slug_url_ref(input: string, expected: string) {
|
|
||||||
let actual = slugurlref(input)
|
|
||||||
expect(actual).toEqual(expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
test('slug_url_ref: master branch', () => {
|
|
||||||
test_slug_url_ref('refs/heads/master', 'master')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url_ref: a feature branch', () => {
|
|
||||||
test_slug_url_ref('refs/heads/feat/new_feature', 'feat-new-feature')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url_ref: a fix branch', () => {
|
|
||||||
test_slug_url_ref('refs/heads/fix/issue_number', 'fix-issue-number')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url_ref: a simple tag', () => {
|
|
||||||
test_slug_url_ref('refs/tags/v1.0.0', 'v1-0-0')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url_ref: a complex tag', () => {
|
|
||||||
test_slug_url_ref('refs/tags/product@1.0.0-rc.2', 'product-1-0-0-rc-2')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url_ref: a reference with upper case letters', () => {
|
|
||||||
test_slug_url_ref('refs/heads/New_Awesome_Product', 'new-awesome-product')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url_ref: a very long name', () => {
|
|
||||||
test_slug_url_ref(
|
|
||||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url_ref: test trailing', () => {
|
|
||||||
test_slug_url_ref('refs/heads/-an-awesome-Feature-', 'an-awesome-feature')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url_ref: test trailing with dot', () => {
|
|
||||||
test_slug_url_ref('refs/heads/.an-awesome-Feature.', 'an-awesome-feature')
|
|
||||||
})
|
|
||||||
14
action.yml
14
action.yml
@@ -1,9 +1,9 @@
|
|||||||
name: "GitHub Slug Action"
|
# action.yml
|
||||||
description: "GitHub Action to expose slug value of environment variables inside your GitHub workflow"
|
name: "GitHub Slug"
|
||||||
author: 'rlespinasse'
|
description: "Action to slug and expose some github variables"
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: "docker"
|
||||||
main: 'dist/index.js'
|
image: "Dockerfile"
|
||||||
branding:
|
branding:
|
||||||
icon: "minimize"
|
icon: "crop"
|
||||||
color: "blue"
|
color: "orange"
|
||||||
|
|||||||
676
dist/index.js
vendored
676
dist/index.js
vendored
@@ -1,676 +0,0 @@
|
|||||||
require('./sourcemap-register.js');module.exports =
|
|
||||||
/******/ (function(modules, runtime) { // webpackBootstrap
|
|
||||||
/******/ "use strict";
|
|
||||||
/******/ // The module cache
|
|
||||||
/******/ var installedModules = {};
|
|
||||||
/******/
|
|
||||||
/******/ // The require function
|
|
||||||
/******/ function __webpack_require__(moduleId) {
|
|
||||||
/******/
|
|
||||||
/******/ // Check if module is in cache
|
|
||||||
/******/ if(installedModules[moduleId]) {
|
|
||||||
/******/ return installedModules[moduleId].exports;
|
|
||||||
/******/ }
|
|
||||||
/******/ // Create a new module (and put it into the cache)
|
|
||||||
/******/ var module = installedModules[moduleId] = {
|
|
||||||
/******/ i: moduleId,
|
|
||||||
/******/ l: false,
|
|
||||||
/******/ exports: {}
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // Execute the module function
|
|
||||||
/******/ var threw = true;
|
|
||||||
/******/ try {
|
|
||||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
||||||
/******/ threw = false;
|
|
||||||
/******/ } finally {
|
|
||||||
/******/ if(threw) delete installedModules[moduleId];
|
|
||||||
/******/ }
|
|
||||||
/******/
|
|
||||||
/******/ // Flag the module as loaded
|
|
||||||
/******/ module.l = true;
|
|
||||||
/******/
|
|
||||||
/******/ // Return the exports of the module
|
|
||||||
/******/ return module.exports;
|
|
||||||
/******/ }
|
|
||||||
/******/
|
|
||||||
/******/
|
|
||||||
/******/ __webpack_require__.ab = __dirname + "/";
|
|
||||||
/******/
|
|
||||||
/******/ // the startup function
|
|
||||||
/******/ function startup() {
|
|
||||||
/******/ // Load entry module and return exports
|
|
||||||
/******/ return __webpack_require__(109);
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // run startup
|
|
||||||
/******/ return startup();
|
|
||||||
/******/ })
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ ({
|
|
||||||
|
|
||||||
/***/ 87:
|
|
||||||
/***/ (function(module) {
|
|
||||||
|
|
||||||
module.exports = require("os");
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 109:
|
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const core = __importStar(__webpack_require__(186));
|
|
||||||
const slug_1 = __webpack_require__(565);
|
|
||||||
/**
|
|
||||||
* Inputs environments variables keys from Github actions job
|
|
||||||
* see https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
||||||
*/
|
|
||||||
const GITHUB_REPOSITORY = 'GITHUB_REPOSITORY';
|
|
||||||
const GITHUB_REF = 'GITHUB_REF';
|
|
||||||
const GITHUB_HEAD_REF = 'GITHUB_HEAD_REF';
|
|
||||||
const GITHUB_BASE_REF = 'GITHUB_BASE_REF';
|
|
||||||
const GITHUB_SHA = 'GITHUB_SHA';
|
|
||||||
const GITHUB_EVENT_PATH = 'GITHUB_EVENT_PATH';
|
|
||||||
/**
|
|
||||||
* Slugged outputs environments variables keys
|
|
||||||
*/
|
|
||||||
const GITHUB_REPOSITORY_SLUG = 'GITHUB_REPOSITORY_SLUG';
|
|
||||||
const GITHUB_REPOSITORY_SLUG_URL = 'GITHUB_REPOSITORY_SLUG_URL';
|
|
||||||
const GITHUB_REF_SLUG = 'GITHUB_REF_SLUG';
|
|
||||||
const GITHUB_HEAD_REF_SLUG = 'GITHUB_HEAD_REF_SLUG';
|
|
||||||
const GITHUB_BASE_REF_SLUG = 'GITHUB_BASE_REF_SLUG';
|
|
||||||
const GITHUB_REF_SLUG_URL = 'GITHUB_REF_SLUG_URL';
|
|
||||||
const GITHUB_HEAD_REF_SLUG_URL = 'GITHUB_HEAD_REF_SLUG_URL';
|
|
||||||
const GITHUB_BASE_REF_SLUG_URL = 'GITHUB_BASE_REF_SLUG_URL';
|
|
||||||
const GITHUB_SHA_SHORT = 'GITHUB_SHA_SHORT';
|
|
||||||
const GITHUB_EVENT_REF_SLUG = 'GITHUB_EVENT_REF_SLUG';
|
|
||||||
const GITHUB_EVENT_REF_SLUG_URL = 'GITHUB_EVENT_REF_SLUG_URL';
|
|
||||||
const GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT = 'GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT';
|
|
||||||
function run() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
const eventPath = process.env[GITHUB_EVENT_PATH];
|
|
||||||
if (eventPath) {
|
|
||||||
const eventData = yield Promise.resolve().then(() => __importStar(require(eventPath)));
|
|
||||||
if (eventData.hasOwnProperty('ref')) {
|
|
||||||
core.exportVariable(GITHUB_EVENT_REF_SLUG, slug_1.slugref(eventData.ref));
|
|
||||||
core.exportVariable(GITHUB_EVENT_REF_SLUG_URL, slug_1.slugurlref(eventData.ref));
|
|
||||||
}
|
|
||||||
else if (eventData.hasOwnProperty('pull_request')) {
|
|
||||||
core.exportVariable(GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT, slug_1.shortsha(eventData.pull_request.head.sha));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exportSlug(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG);
|
|
||||||
exportSlugUrl(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL);
|
|
||||||
exportSlugRef(GITHUB_REF, GITHUB_REF_SLUG);
|
|
||||||
exportSlugRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG);
|
|
||||||
exportSlugRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG);
|
|
||||||
exportSlugUrlRef(GITHUB_REF, GITHUB_REF_SLUG_URL);
|
|
||||||
exportSlugUrlRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_URL);
|
|
||||||
exportSlugUrlRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_URL);
|
|
||||||
exportShortSha(GITHUB_SHA, GITHUB_SHA_SHORT);
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
core.setFailed(error.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function exportSlug(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, slug_1.slug(envVar));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSlugRef(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, slug_1.slugref(envVar));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSlugUrl(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, slug_1.slugurl(envVar));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSlugUrlRef(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, slug_1.slugurlref(envVar));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportShortSha(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, slug_1.shortsha(envVar));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
run();
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 186:
|
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const command_1 = __webpack_require__(351);
|
|
||||||
const file_command_1 = __webpack_require__(717);
|
|
||||||
const utils_1 = __webpack_require__(278);
|
|
||||||
const os = __importStar(__webpack_require__(87));
|
|
||||||
const path = __importStar(__webpack_require__(622));
|
|
||||||
/**
|
|
||||||
* The code to exit an action
|
|
||||||
*/
|
|
||||||
var ExitCode;
|
|
||||||
(function (ExitCode) {
|
|
||||||
/**
|
|
||||||
* A code indicating that the action was successful
|
|
||||||
*/
|
|
||||||
ExitCode[ExitCode["Success"] = 0] = "Success";
|
|
||||||
/**
|
|
||||||
* A code indicating that the action was a failure
|
|
||||||
*/
|
|
||||||
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
|
||||||
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Variables
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Sets env variable for this action and future actions in the job
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
function exportVariable(name, val) {
|
|
||||||
const convertedVal = utils_1.toCommandValue(val);
|
|
||||||
process.env[name] = convertedVal;
|
|
||||||
const filePath = process.env['GITHUB_ENV'] || '';
|
|
||||||
if (filePath) {
|
|
||||||
const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
|
||||||
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
|
||||||
file_command_1.issueCommand('ENV', commandValue);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.exportVariable = exportVariable;
|
|
||||||
/**
|
|
||||||
* Registers a secret which will get masked from logs
|
|
||||||
* @param secret value of the secret
|
|
||||||
*/
|
|
||||||
function setSecret(secret) {
|
|
||||||
command_1.issueCommand('add-mask', {}, secret);
|
|
||||||
}
|
|
||||||
exports.setSecret = setSecret;
|
|
||||||
/**
|
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
|
||||||
* @param inputPath
|
|
||||||
*/
|
|
||||||
function addPath(inputPath) {
|
|
||||||
const filePath = process.env['GITHUB_PATH'] || '';
|
|
||||||
if (filePath) {
|
|
||||||
file_command_1.issueCommand('PATH', inputPath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
|
||||||
}
|
|
||||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
|
||||||
}
|
|
||||||
exports.addPath = addPath;
|
|
||||||
/**
|
|
||||||
* Gets the value of an input. The value is also trimmed.
|
|
||||||
*
|
|
||||||
* @param name name of the input to get
|
|
||||||
* @param options optional. See InputOptions.
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
function getInput(name, options) {
|
|
||||||
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
|
||||||
if (options && options.required && !val) {
|
|
||||||
throw new Error(`Input required and not supplied: ${name}`);
|
|
||||||
}
|
|
||||||
return val.trim();
|
|
||||||
}
|
|
||||||
exports.getInput = getInput;
|
|
||||||
/**
|
|
||||||
* Sets the value of an output.
|
|
||||||
*
|
|
||||||
* @param name name of the output to set
|
|
||||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
function setOutput(name, value) {
|
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
|
||||||
}
|
|
||||||
exports.setOutput = setOutput;
|
|
||||||
/**
|
|
||||||
* Enables or disables the echoing of commands into stdout for the rest of the step.
|
|
||||||
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function setCommandEcho(enabled) {
|
|
||||||
command_1.issue('echo', enabled ? 'on' : 'off');
|
|
||||||
}
|
|
||||||
exports.setCommandEcho = setCommandEcho;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Results
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Sets the action status to failed.
|
|
||||||
* When the action exits it will be with an exit code of 1
|
|
||||||
* @param message add error issue message
|
|
||||||
*/
|
|
||||||
function setFailed(message) {
|
|
||||||
process.exitCode = ExitCode.Failure;
|
|
||||||
error(message);
|
|
||||||
}
|
|
||||||
exports.setFailed = setFailed;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Logging Commands
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Gets whether Actions Step Debug is on or not
|
|
||||||
*/
|
|
||||||
function isDebug() {
|
|
||||||
return process.env['RUNNER_DEBUG'] === '1';
|
|
||||||
}
|
|
||||||
exports.isDebug = isDebug;
|
|
||||||
/**
|
|
||||||
* Writes debug message to user log
|
|
||||||
* @param message debug message
|
|
||||||
*/
|
|
||||||
function debug(message) {
|
|
||||||
command_1.issueCommand('debug', {}, message);
|
|
||||||
}
|
|
||||||
exports.debug = debug;
|
|
||||||
/**
|
|
||||||
* Adds an error issue
|
|
||||||
* @param message error issue message. Errors will be converted to string via toString()
|
|
||||||
*/
|
|
||||||
function error(message) {
|
|
||||||
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
|
||||||
}
|
|
||||||
exports.error = error;
|
|
||||||
/**
|
|
||||||
* Adds an warning issue
|
|
||||||
* @param message warning issue message. Errors will be converted to string via toString()
|
|
||||||
*/
|
|
||||||
function warning(message) {
|
|
||||||
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
|
||||||
}
|
|
||||||
exports.warning = warning;
|
|
||||||
/**
|
|
||||||
* Writes info to log with console.log.
|
|
||||||
* @param message info message
|
|
||||||
*/
|
|
||||||
function info(message) {
|
|
||||||
process.stdout.write(message + os.EOL);
|
|
||||||
}
|
|
||||||
exports.info = info;
|
|
||||||
/**
|
|
||||||
* Begin an output group.
|
|
||||||
*
|
|
||||||
* Output until the next `groupEnd` will be foldable in this group
|
|
||||||
*
|
|
||||||
* @param name The name of the output group
|
|
||||||
*/
|
|
||||||
function startGroup(name) {
|
|
||||||
command_1.issue('group', name);
|
|
||||||
}
|
|
||||||
exports.startGroup = startGroup;
|
|
||||||
/**
|
|
||||||
* End an output group.
|
|
||||||
*/
|
|
||||||
function endGroup() {
|
|
||||||
command_1.issue('endgroup');
|
|
||||||
}
|
|
||||||
exports.endGroup = endGroup;
|
|
||||||
/**
|
|
||||||
* Wrap an asynchronous function call in a group.
|
|
||||||
*
|
|
||||||
* Returns the same type as the function itself.
|
|
||||||
*
|
|
||||||
* @param name The name of the group
|
|
||||||
* @param fn The function to wrap in the group
|
|
||||||
*/
|
|
||||||
function group(name, fn) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
startGroup(name);
|
|
||||||
let result;
|
|
||||||
try {
|
|
||||||
result = yield fn();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
endGroup();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.group = group;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Wrapper action state
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
|
||||||
*
|
|
||||||
* @param name name of the state to store
|
|
||||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
function saveState(name, value) {
|
|
||||||
command_1.issueCommand('save-state', { name }, value);
|
|
||||||
}
|
|
||||||
exports.saveState = saveState;
|
|
||||||
/**
|
|
||||||
* Gets the value of an state set by this action's main execution.
|
|
||||||
*
|
|
||||||
* @param name name of the state to get
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
function getState(name) {
|
|
||||||
return process.env[`STATE_${name}`] || '';
|
|
||||||
}
|
|
||||||
exports.getState = getState;
|
|
||||||
//# sourceMappingURL=core.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 278:
|
|
||||||
/***/ (function(__unusedmodule, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// We use any as a valid input type
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
/**
|
|
||||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
|
||||||
* @param input input to sanitize into a string
|
|
||||||
*/
|
|
||||||
function toCommandValue(input) {
|
|
||||||
if (input === null || input === undefined) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
else if (typeof input === 'string' || input instanceof String) {
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
return JSON.stringify(input);
|
|
||||||
}
|
|
||||||
exports.toCommandValue = toCommandValue;
|
|
||||||
//# sourceMappingURL=utils.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 351:
|
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const os = __importStar(__webpack_require__(87));
|
|
||||||
const utils_1 = __webpack_require__(278);
|
|
||||||
/**
|
|
||||||
* Commands
|
|
||||||
*
|
|
||||||
* Command Format:
|
|
||||||
* ::name key=value,key=value::message
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ::warning::This is the message
|
|
||||||
* ::set-env name=MY_VAR::some value
|
|
||||||
*/
|
|
||||||
function issueCommand(command, properties, message) {
|
|
||||||
const cmd = new Command(command, properties, message);
|
|
||||||
process.stdout.write(cmd.toString() + os.EOL);
|
|
||||||
}
|
|
||||||
exports.issueCommand = issueCommand;
|
|
||||||
function issue(name, message = '') {
|
|
||||||
issueCommand(name, {}, message);
|
|
||||||
}
|
|
||||||
exports.issue = issue;
|
|
||||||
const CMD_STRING = '::';
|
|
||||||
class Command {
|
|
||||||
constructor(command, properties, message) {
|
|
||||||
if (!command) {
|
|
||||||
command = 'missing.command';
|
|
||||||
}
|
|
||||||
this.command = command;
|
|
||||||
this.properties = properties;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
let cmdStr = CMD_STRING + this.command;
|
|
||||||
if (this.properties && Object.keys(this.properties).length > 0) {
|
|
||||||
cmdStr += ' ';
|
|
||||||
let first = true;
|
|
||||||
for (const key in this.properties) {
|
|
||||||
if (this.properties.hasOwnProperty(key)) {
|
|
||||||
const val = this.properties[key];
|
|
||||||
if (val) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cmdStr += ',';
|
|
||||||
}
|
|
||||||
cmdStr += `${key}=${escapeProperty(val)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
|
|
||||||
return cmdStr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function escapeData(s) {
|
|
||||||
return utils_1.toCommandValue(s)
|
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/\r/g, '%0D')
|
|
||||||
.replace(/\n/g, '%0A');
|
|
||||||
}
|
|
||||||
function escapeProperty(s) {
|
|
||||||
return utils_1.toCommandValue(s)
|
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/\r/g, '%0D')
|
|
||||||
.replace(/\n/g, '%0A')
|
|
||||||
.replace(/:/g, '%3A')
|
|
||||||
.replace(/,/g, '%2C');
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=command.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 565:
|
|
||||||
/***/ (function(__unusedmodule, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.shortsha = exports.slugurlref = exports.slugurl = exports.slugref = exports.slug = void 0;
|
|
||||||
const MAX_SLUG_STRING_SIZE = 63;
|
|
||||||
const SHORT_SHA_SIZE = 8;
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - put the variable content in lower case
|
|
||||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
|
||||||
* - remove leading and trailing `-` character
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
function slug(envVar) {
|
|
||||||
return trailHyphen(replaceAnyNonAlphanumericCaracter(envVar.toLowerCase())).substring(0, MAX_SLUG_STRING_SIZE);
|
|
||||||
}
|
|
||||||
exports.slug = slug;
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - remove refs/(heads|tags)/
|
|
||||||
* - put the variable content in lower case
|
|
||||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
|
||||||
* - remove leading and trailing `-` character
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
function slugref(envVar) {
|
|
||||||
return slug(removeRef(envVar.toLowerCase()));
|
|
||||||
}
|
|
||||||
exports.slugref = slugref;
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - put the variable content in lower case
|
|
||||||
* - replace any character by `-` except `0-9`, `a-z`
|
|
||||||
* - remove leading and trailing `-` character
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
function slugurl(envVar) {
|
|
||||||
return slug(replaceAnyDotToHyphen(envVar));
|
|
||||||
}
|
|
||||||
exports.slugurl = slugurl;
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - remove refs/(heads|tags)/
|
|
||||||
* - put the variable content in lower case
|
|
||||||
* - replace any character by `-` except `0-9`, `a-z`
|
|
||||||
* - remove leading and trailing `-` character
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
function slugurlref(envVar) {
|
|
||||||
return slugurl(slugref(envVar));
|
|
||||||
}
|
|
||||||
exports.slugurlref = slugurlref;
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - limit the string size to 8 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
function shortsha(envVar) {
|
|
||||||
return envVar.substring(0, SHORT_SHA_SIZE);
|
|
||||||
}
|
|
||||||
exports.shortsha = shortsha;
|
|
||||||
function trailHyphen(envVar) {
|
|
||||||
return envVar.replace(RegExp('^-*', 'g'), '').replace(RegExp('-*$', 'g'), '');
|
|
||||||
}
|
|
||||||
function replaceAnyNonAlphanumericCaracter(envVar) {
|
|
||||||
return envVar.replace(RegExp('[^a-z0-9.]', 'g'), '-');
|
|
||||||
}
|
|
||||||
function replaceAnyDotToHyphen(envVar) {
|
|
||||||
return envVar.replace(RegExp('[.]', 'g'), '-');
|
|
||||||
}
|
|
||||||
function removeRef(envVar) {
|
|
||||||
return envVar.replace(RegExp('^refs/(heads|tags)/'), '');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 622:
|
|
||||||
/***/ (function(module) {
|
|
||||||
|
|
||||||
module.exports = require("path");
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 717:
|
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// For internal use, subject to change.
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// We use any as a valid input type
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
const fs = __importStar(__webpack_require__(747));
|
|
||||||
const os = __importStar(__webpack_require__(87));
|
|
||||||
const utils_1 = __webpack_require__(278);
|
|
||||||
function issueCommand(command, message) {
|
|
||||||
const filePath = process.env[`GITHUB_${command}`];
|
|
||||||
if (!filePath) {
|
|
||||||
throw new Error(`Unable to find environment variable for file command ${command}`);
|
|
||||||
}
|
|
||||||
if (!fs.existsSync(filePath)) {
|
|
||||||
throw new Error(`Missing file at path: ${filePath}`);
|
|
||||||
}
|
|
||||||
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
|
|
||||||
encoding: 'utf8'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.issueCommand = issueCommand;
|
|
||||||
//# sourceMappingURL=file-command.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 747:
|
|
||||||
/***/ (function(module) {
|
|
||||||
|
|
||||||
module.exports = require("fs");
|
|
||||||
|
|
||||||
/***/ })
|
|
||||||
|
|
||||||
/******/ });
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
||||||
1
dist/index.js.map
vendored
1
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
3912
dist/sourcemap-register.js
vendored
3912
dist/sourcemap-register.js
vendored
File diff suppressed because it is too large
Load Diff
56
entrypoint.sh
Executable file
56
entrypoint.sh
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/sh -l
|
||||||
|
|
||||||
|
slug() {
|
||||||
|
echo "$1" |
|
||||||
|
tr "[:upper:]" "[:lower:]" |
|
||||||
|
sed -r 's/[~\^]+//g;s/[^a-zA-Z0-9.]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
||||||
|
cut -c1-63
|
||||||
|
}
|
||||||
|
|
||||||
|
slug_url() {
|
||||||
|
echo "$1" |
|
||||||
|
tr "[:upper:]" "[:lower:]" |
|
||||||
|
sed -r 's/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
||||||
|
cut -c1-63
|
||||||
|
}
|
||||||
|
|
||||||
|
slug_ref() {
|
||||||
|
echo "$1" |
|
||||||
|
tr "[:upper:]" "[:lower:]" |
|
||||||
|
sed -r 's#refs/[^\/]*/##;s/[~\^]+//g;s/[^a-zA-Z0-9.]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
||||||
|
cut -c1-63
|
||||||
|
}
|
||||||
|
|
||||||
|
slug_url_ref() {
|
||||||
|
echo "$1" |
|
||||||
|
tr "[:upper:]" "[:lower:]" |
|
||||||
|
sed -r 's#refs/[^\/]*/##;s/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
||||||
|
cut -c1-63
|
||||||
|
}
|
||||||
|
|
||||||
|
short_sha() {
|
||||||
|
echo "$1" |
|
||||||
|
cut -c1-8
|
||||||
|
}
|
||||||
|
|
||||||
|
get_event_keyvalue() {
|
||||||
|
if [ -f "$GITHUB_EVENT_PATH" ]; then
|
||||||
|
jq -r ".$1" "$GITHUB_EVENT_PATH" | grep -v "null"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "GITHUB_REPOSITORY_SLUG=$(slug "$GITHUB_REPOSITORY")"
|
||||||
|
echo "GITHUB_REPOSITORY_SLUG_URL=$(slug_url "$GITHUB_REPOSITORY")"
|
||||||
|
echo "GITHUB_REF_SLUG=$(slug_ref "$GITHUB_REF")"
|
||||||
|
echo "GITHUB_HEAD_REF_SLUG=$(slug_ref "$GITHUB_HEAD_REF")"
|
||||||
|
echo "GITHUB_BASE_REF_SLUG=$(slug_ref "$GITHUB_BASE_REF")"
|
||||||
|
echo "GITHUB_EVENT_REF_SLUG=$(slug_ref "$(get_event_keyvalue "ref")")"
|
||||||
|
echo "GITHUB_REF_SLUG_URL=$(slug_url_ref "$GITHUB_REF")"
|
||||||
|
echo "GITHUB_HEAD_REF_SLUG_URL=$(slug_url_ref "$GITHUB_HEAD_REF")"
|
||||||
|
echo "GITHUB_BASE_REF_SLUG_URL=$(slug_url_ref "$GITHUB_BASE_REF")"
|
||||||
|
echo "GITHUB_EVENT_REF_SLUG_URL=$(slug_url_ref "$(get_event_keyvalue "ref")")"
|
||||||
|
echo "GITHUB_SHA_SHORT=$(short_sha "$GITHUB_SHA")"
|
||||||
|
} >>"$GITHUB_ENV"
|
||||||
|
|
||||||
|
echo "::warning ::This version only support linux-based workflow, please use 'rlespinasse/github-slug-action@v3.x' instead"
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
clearMocks: true,
|
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
testMatch: ['**/*.test.ts'],
|
|
||||||
testRunner: 'jest-circus/runner',
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': 'ts-jest'
|
|
||||||
},
|
|
||||||
verbose: true
|
|
||||||
}
|
|
||||||
6796
package-lock.json
generated
6796
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -2,49 +2,18 @@
|
|||||||
"name": "github-slug-action",
|
"name": "github-slug-action",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
|
||||||
"description": "Github slug action",
|
|
||||||
"main": "lib/main.js",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"release": "semantic-release",
|
"test": "docker run -w /workdir -v $(pwd):/workdir ffurrer/bats:latest --recursive .",
|
||||||
"build": "tsc",
|
"release": "semantic-release"
|
||||||
"format": "prettier --write **/*.ts",
|
|
||||||
"format-check": "prettier --check **/*.ts",
|
|
||||||
"lint": "eslint src/**/*.ts",
|
|
||||||
"package": "ncc build --source-map",
|
|
||||||
"test": "jest",
|
|
||||||
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "http://github.com/rlespinasse/github-slug-action.git"
|
"url": "http://github.com/rlespinasse/github-slug-action.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
|
||||||
"actions",
|
|
||||||
"node",
|
|
||||||
"setup"
|
|
||||||
],
|
|
||||||
"author": "rlespinasse",
|
|
||||||
"dependencies": {
|
|
||||||
"@actions/core": "^1.2.6"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@semantic-release/changelog": "5.0.1",
|
"@semantic-release/changelog": "5.0.1",
|
||||||
"@semantic-release/git": "9.0.0",
|
"@semantic-release/git": "9.0.0",
|
||||||
"@types/jest": "^26.0.15",
|
"semantic-release": "17.0.7"
|
||||||
"@types/node": "^14.14.3",
|
|
||||||
"@typescript-eslint/parser": "^3.9.1",
|
|
||||||
"@vercel/ncc": "^0.23.0",
|
|
||||||
"eslint": "^7.12.0",
|
|
||||||
"eslint-plugin-github": "^4.1.1",
|
|
||||||
"eslint-plugin-jest": "^23.20.0",
|
|
||||||
"jest": "^26.6.1",
|
|
||||||
"jest-circus": "^26.6.1",
|
|
||||||
"js-yaml": "^3.14.0",
|
|
||||||
"prettier": "2.0.5",
|
|
||||||
"semantic-release": "17.2.3",
|
|
||||||
"ts-jest": "^26.4.2",
|
|
||||||
"typescript": "^3.9.7"
|
|
||||||
},
|
},
|
||||||
"release": {
|
"release": {
|
||||||
"tagFormat": "${version}",
|
"tagFormat": "${version}",
|
||||||
@@ -56,8 +25,8 @@
|
|||||||
"@semantic-release/github"
|
"@semantic-release/github"
|
||||||
],
|
],
|
||||||
"branches": [
|
"branches": [
|
||||||
"v2.x",
|
"v1.1.x",
|
||||||
"v3.x"
|
"v2.x"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
104
src/main.ts
104
src/main.ts
@@ -1,104 +0,0 @@
|
|||||||
import * as core from '@actions/core'
|
|
||||||
import {slugref, slug, slugurl, slugurlref, shortsha} from './slug'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inputs environments variables keys from Github actions job
|
|
||||||
* see https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
||||||
*/
|
|
||||||
const GITHUB_REPOSITORY = 'GITHUB_REPOSITORY'
|
|
||||||
const GITHUB_REF = 'GITHUB_REF'
|
|
||||||
const GITHUB_HEAD_REF = 'GITHUB_HEAD_REF'
|
|
||||||
const GITHUB_BASE_REF = 'GITHUB_BASE_REF'
|
|
||||||
const GITHUB_SHA = 'GITHUB_SHA'
|
|
||||||
const GITHUB_EVENT_PATH = 'GITHUB_EVENT_PATH'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Slugged outputs environments variables keys
|
|
||||||
*/
|
|
||||||
const GITHUB_REPOSITORY_SLUG = 'GITHUB_REPOSITORY_SLUG'
|
|
||||||
const GITHUB_REPOSITORY_SLUG_URL = 'GITHUB_REPOSITORY_SLUG_URL'
|
|
||||||
const GITHUB_REF_SLUG = 'GITHUB_REF_SLUG'
|
|
||||||
const GITHUB_HEAD_REF_SLUG = 'GITHUB_HEAD_REF_SLUG'
|
|
||||||
const GITHUB_BASE_REF_SLUG = 'GITHUB_BASE_REF_SLUG'
|
|
||||||
const GITHUB_REF_SLUG_URL = 'GITHUB_REF_SLUG_URL'
|
|
||||||
const GITHUB_HEAD_REF_SLUG_URL = 'GITHUB_HEAD_REF_SLUG_URL'
|
|
||||||
const GITHUB_BASE_REF_SLUG_URL = 'GITHUB_BASE_REF_SLUG_URL'
|
|
||||||
const GITHUB_SHA_SHORT = 'GITHUB_SHA_SHORT'
|
|
||||||
const GITHUB_EVENT_REF_SLUG = 'GITHUB_EVENT_REF_SLUG'
|
|
||||||
const GITHUB_EVENT_REF_SLUG_URL = 'GITHUB_EVENT_REF_SLUG_URL'
|
|
||||||
const GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT =
|
|
||||||
'GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT'
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
|
||||||
try {
|
|
||||||
const eventPath = process.env[GITHUB_EVENT_PATH]
|
|
||||||
if (eventPath) {
|
|
||||||
const eventData = await import(eventPath)
|
|
||||||
if (eventData.hasOwnProperty('ref')) {
|
|
||||||
core.exportVariable(GITHUB_EVENT_REF_SLUG, slugref(eventData.ref))
|
|
||||||
core.exportVariable(
|
|
||||||
GITHUB_EVENT_REF_SLUG_URL,
|
|
||||||
slugurlref(eventData.ref)
|
|
||||||
)
|
|
||||||
} else if (eventData.hasOwnProperty('pull_request')) {
|
|
||||||
core.exportVariable(
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT,
|
|
||||||
shortsha(eventData.pull_request.head.sha)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exportSlug(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG)
|
|
||||||
|
|
||||||
exportSlugUrl(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL)
|
|
||||||
|
|
||||||
exportSlugRef(GITHUB_REF, GITHUB_REF_SLUG)
|
|
||||||
exportSlugRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG)
|
|
||||||
exportSlugRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG)
|
|
||||||
|
|
||||||
exportSlugUrlRef(GITHUB_REF, GITHUB_REF_SLUG_URL)
|
|
||||||
exportSlugUrlRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_URL)
|
|
||||||
exportSlugUrlRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_URL)
|
|
||||||
|
|
||||||
exportShortSha(GITHUB_SHA, GITHUB_SHA_SHORT)
|
|
||||||
} catch (error) {
|
|
||||||
core.setFailed(error.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlug(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, slug(envVar))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugRef(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, slugref(envVar))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugUrl(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, slugurl(envVar))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugUrlRef(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, slugurlref(envVar))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportShortSha(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, shortsha(envVar))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
run()
|
|
||||||
79
src/slug.ts
79
src/slug.ts
@@ -1,79 +0,0 @@
|
|||||||
const MAX_SLUG_STRING_SIZE = 63
|
|
||||||
const SHORT_SHA_SIZE = 8
|
|
||||||
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - put the variable content in lower case
|
|
||||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
|
||||||
* - remove leading and trailing `-` character
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
export function slug(envVar: string): string {
|
|
||||||
return trailHyphen(
|
|
||||||
replaceAnyNonAlphanumericCaracter(envVar.toLowerCase())
|
|
||||||
).substring(0, MAX_SLUG_STRING_SIZE)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - remove refs/(heads|tags)/
|
|
||||||
* - put the variable content in lower case
|
|
||||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
|
||||||
* - remove leading and trailing `-` character
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
export function slugref(envVar: string): string {
|
|
||||||
return slug(removeRef(envVar.toLowerCase()))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - put the variable content in lower case
|
|
||||||
* - replace any character by `-` except `0-9`, `a-z`
|
|
||||||
* - remove leading and trailing `-` character
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
export function slugurl(envVar: string): string {
|
|
||||||
return slug(replaceAnyDotToHyphen(envVar))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - remove refs/(heads|tags)/
|
|
||||||
* - put the variable content in lower case
|
|
||||||
* - replace any character by `-` except `0-9`, `a-z`
|
|
||||||
* - remove leading and trailing `-` character
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
export function slugurlref(envVar: string): string {
|
|
||||||
return slugurl(slugref(envVar))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - limit the string size to 8 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
export function shortsha(envVar: string): string {
|
|
||||||
return envVar.substring(0, SHORT_SHA_SIZE)
|
|
||||||
}
|
|
||||||
|
|
||||||
function trailHyphen(envVar: string): string {
|
|
||||||
return envVar.replace(RegExp('^-*', 'g'), '').replace(RegExp('-*$', 'g'), '')
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceAnyNonAlphanumericCaracter(envVar: string): string {
|
|
||||||
return envVar.replace(RegExp('[^a-z0-9.]', 'g'), '-')
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceAnyDotToHyphen(envVar: string): string {
|
|
||||||
return envVar.replace(RegExp('[.]', 'g'), '-')
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeRef(envVar: string): string {
|
|
||||||
return envVar.replace(RegExp('^refs/(heads|tags)/'), '')
|
|
||||||
}
|
|
||||||
19
tests/short_sha.bats
Normal file
19
tests/short_sha.bats
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
@test "short_sha: long hash" {
|
||||||
|
test_short_sha \
|
||||||
|
"a35a1a486a260cfd99c5b6f8c6034a2929ba9b3f" \
|
||||||
|
"a35a1a48"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load sluf_ref function
|
||||||
|
source entrypoint.sh > /dev/null 2>&1
|
||||||
|
|
||||||
|
test_short_sha(){
|
||||||
|
given="${1}"
|
||||||
|
expected="${2}"
|
||||||
|
|
||||||
|
actual="$(short_sha ${given})"
|
||||||
|
echo "expected : [${expected}], actual : [${actual}]"
|
||||||
|
[ "${actual}" == "${expected}" ]
|
||||||
|
}
|
||||||
49
tests/slug.bats
Normal file
49
tests/slug.bats
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
@test "slug: a word" {
|
||||||
|
test_slug \
|
||||||
|
"word" \
|
||||||
|
"word"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug: a string" {
|
||||||
|
test_slug \
|
||||||
|
"basic-string" \
|
||||||
|
"basic-string"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug: a string in camel case" {
|
||||||
|
test_slug \
|
||||||
|
"camelCase" \
|
||||||
|
"camelcase"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug: a path" {
|
||||||
|
test_slug \
|
||||||
|
"path/to/something" \
|
||||||
|
"path-to-something"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug: a number" {
|
||||||
|
test_slug \
|
||||||
|
"4.2" \
|
||||||
|
"4.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug: a very long string" {
|
||||||
|
test_slug \
|
||||||
|
"an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters" \
|
||||||
|
"an-awesome-feature-very-very-very-very-very-very-very-long-more"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load sluf_ref function
|
||||||
|
source entrypoint.sh > /dev/null 2>&1
|
||||||
|
|
||||||
|
test_slug() {
|
||||||
|
given="${1}"
|
||||||
|
expected="${2}"
|
||||||
|
|
||||||
|
actual="$(slug \"${given}\")"
|
||||||
|
echo "expected : [${expected}], actual : [${actual}]"
|
||||||
|
[ "${actual}" == "${expected}" ]
|
||||||
|
}
|
||||||
55
tests/slug_ref.bats
Normal file
55
tests/slug_ref.bats
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
@test "slug_ref:: master branch" {
|
||||||
|
test_slug_ref \
|
||||||
|
"refs/heads/master" \
|
||||||
|
"master"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_ref: a feature branch" {
|
||||||
|
test_slug_ref \
|
||||||
|
"refs/heads/feat/new_feature" \
|
||||||
|
"feat-new-feature"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_ref: a fix branch" {
|
||||||
|
test_slug_ref \
|
||||||
|
"refs/heads/fix/issue_number" \
|
||||||
|
"fix-issue-number"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_ref: a simple tag" {
|
||||||
|
test_slug_ref \
|
||||||
|
"refs/tags/v1.0.0" \
|
||||||
|
"v1.0.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_ref: a complex tag" {
|
||||||
|
test_slug_ref \
|
||||||
|
"refs/tags/product@1.0.0-rc.2" \
|
||||||
|
"product-1.0.0-rc.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_ref: a reference with upper case letters" {
|
||||||
|
test_slug_ref \
|
||||||
|
"refs/heads/New_Awesome_Product" \
|
||||||
|
"new-awesome-product"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_ref: a very long name" {
|
||||||
|
test_slug_ref \
|
||||||
|
"refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters" \
|
||||||
|
"an-awesome-feature-very-very-very-very-very-very-very-long-more"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load sluf_ref function
|
||||||
|
source entrypoint.sh > /dev/null 2>&1
|
||||||
|
|
||||||
|
test_slug_ref() {
|
||||||
|
given="${1}"
|
||||||
|
expected="${2}"
|
||||||
|
|
||||||
|
actual="$(slug_ref \"${given}\")"
|
||||||
|
echo "expected : [${expected}], actual : [${actual}]"
|
||||||
|
[ "${actual}" == "${expected}" ]
|
||||||
|
}
|
||||||
49
tests/slug_url.bats
Normal file
49
tests/slug_url.bats
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
@test "slug_url: a word" {
|
||||||
|
test_slug_url \
|
||||||
|
"word" \
|
||||||
|
"word"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url: a string" {
|
||||||
|
test_slug_url \
|
||||||
|
"basic-string" \
|
||||||
|
"basic-string"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url: a string in camel case" {
|
||||||
|
test_slug_url \
|
||||||
|
"camelCase" \
|
||||||
|
"camelcase"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url: a path" {
|
||||||
|
test_slug_url \
|
||||||
|
"path/to/something" \
|
||||||
|
"path-to-something"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url: a number" {
|
||||||
|
test_slug_url \
|
||||||
|
"4.2" \
|
||||||
|
"4-2"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url: a very long string" {
|
||||||
|
test_slug_url \
|
||||||
|
"an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters" \
|
||||||
|
"an-awesome-feature-very-very-very-very-very-very-very-long-more"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load sluf_ref function
|
||||||
|
source entrypoint.sh > /dev/null 2>&1
|
||||||
|
|
||||||
|
test_slug_url() {
|
||||||
|
given="${1}"
|
||||||
|
expected="${2}"
|
||||||
|
|
||||||
|
actual="$(slug_url \"${given}\")"
|
||||||
|
echo "expected : [${expected}], actual : [${actual}]"
|
||||||
|
[ "${actual}" == "${expected}" ]
|
||||||
|
}
|
||||||
55
tests/slug_url_ref.bats
Normal file
55
tests/slug_url_ref.bats
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
@test "slug_url_ref: master branch" {
|
||||||
|
test_slug_url_ref \
|
||||||
|
"refs/heads/master" \
|
||||||
|
"master"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url_ref: a feature branch" {
|
||||||
|
test_slug_url_ref \
|
||||||
|
"refs/heads/feat/new_feature" \
|
||||||
|
"feat-new-feature"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url_ref: a fix branch" {
|
||||||
|
test_slug_url_ref \
|
||||||
|
"refs/heads/fix/issue_number" \
|
||||||
|
"fix-issue-number"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url_ref: a simple tag" {
|
||||||
|
test_slug_url_ref \
|
||||||
|
"refs/tags/v1.0.0" \
|
||||||
|
"v1-0-0"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url_ref: a complex tag" {
|
||||||
|
test_slug_url_ref \
|
||||||
|
"refs/tags/product@1.0.0-rc.2" \
|
||||||
|
"product-1-0-0-rc-2"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url_ref: a reference with upper case letters" {
|
||||||
|
test_slug_url_ref \
|
||||||
|
"refs/heads/New_Awesome_Product" \
|
||||||
|
"new-awesome-product"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "slug_url_ref: a very long name" {
|
||||||
|
test_slug_url_ref \
|
||||||
|
"refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters" \
|
||||||
|
"an-awesome-feature-very-very-very-very-very-very-very-long-more"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load sluf_ref function
|
||||||
|
source entrypoint.sh > /dev/null 2>&1
|
||||||
|
|
||||||
|
test_slug_url_ref() {
|
||||||
|
given="${1}"
|
||||||
|
expected="${2}"
|
||||||
|
|
||||||
|
actual="$(slug_url_ref \"${given}\")"
|
||||||
|
echo "expected : [${expected}], actual : [${actual}]"
|
||||||
|
[ "${actual}" == "${expected}" ]
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
|
||||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
|
||||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
|
||||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
||||||
},
|
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user