mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-05-18 09:11:43 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8d8ee50d0 | ||
|
|
5b9fe6015d | ||
|
|
5629d21ee9 | ||
|
|
b6938fb2bd | ||
|
|
d6257a36a9 | ||
|
|
7ad978282a | ||
|
|
9f5fafb8ad | ||
|
|
750d2f7f48 | ||
|
|
2b1034b1fb | ||
|
|
1b1913be6c | ||
|
|
cc560ad7b4 | ||
|
|
549c11b4e2 | ||
|
|
68eb43656c | ||
|
|
2aba10a826 | ||
|
|
afcda09378 | ||
|
|
15f6edebdd | ||
|
|
e4699e49fc | ||
|
|
3cddc4f12d | ||
|
|
d7817bf204 | ||
|
|
4e3f956c5e | ||
|
|
f79727b5cc | ||
|
|
a3c7c5c7a1 | ||
|
|
008aa6260d | ||
|
|
3c7ae42a01 | ||
|
|
ae2430ad57 |
6
.dependabot/config.xml
Normal file
6
.dependabot/config.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
9
.github/dependabot.yml
vendored
9
.github/dependabot.yml
vendored
@@ -1,9 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Enable version updates for npm
|
||||
- package-ecosystem: 'npm'
|
||||
# Look for `package.json` and `lock` files in the `root` directory
|
||||
directory: '/'
|
||||
# Check the npm registry for updates every day (weekdays)
|
||||
schedule:
|
||||
interval: 'daily'
|
||||
@@ -1,5 +1,10 @@
|
||||
name: Build
|
||||
on: [push, pull_request]
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- v3.x
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -45,6 +50,7 @@ jobs:
|
||||
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
|
||||
@@ -63,3 +69,4 @@ jobs:
|
||||
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
|
||||
34
.github/workflows/codeql-analysis.yml
vendored
Normal file
34
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
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
Normal file
29
.github/workflows/linter.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
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/.*
|
||||
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,17 @@
|
||||
# [3.2.0](http://github.com/rlespinasse/github-slug-action/compare/3.1.0...3.2.0) (2021-01-12)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* expose GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT ([5b9fe60](http://github.com/rlespinasse/github-slug-action/commit/5b9fe6015d2facc71c81d53bf3b08f04e0f3f743))
|
||||
|
||||
# [3.1.0](http://github.com/rlespinasse/github-slug-action/compare/3.0.0...3.1.0) (2020-11-01)
|
||||
|
||||
|
||||
### 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)
|
||||
|
||||
|
||||
|
||||
33
CONTRIBUTING.md
Normal file
33
CONTRIBUTING.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# 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=
|
||||
69
README.md
69
README.md
@@ -1,9 +1,11 @@
|
||||
# GitHub Slug action
|
||||
|
||||
[![Actions Status][1]][2]
|
||||
![GitHub Super-Linter][13]
|
||||
[![Public workflows that use this action.][8]][9]
|
||||
[![Licence][11]][12]
|
||||
|
||||
This action slug and expose some github variables.
|
||||
This GitHub Action will expose the slug value of all [GitHub environment variables][10] inside your GitHub workflow.
|
||||
|
||||
`Slug` a variable will
|
||||
|
||||
@@ -17,32 +19,35 @@ Others `Slug`-ish commands are available:
|
||||
- `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
|
||||
|
||||
## Exposed environment variables
|
||||
## Exposed GitHub environment variables
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v2.x
|
||||
uses: rlespinasse/github-slug-action@v3.x
|
||||
|
||||
- name: Print slug/short variables
|
||||
run: |
|
||||
echo "Slug variables"
|
||||
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 " 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 " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
|
||||
echo "Slug URL variables"
|
||||
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 " 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 " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
||||
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.
|
||||
|
||||
**TIP:** Use [Dependabot][14] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
||||
|
||||
### GITHUB_REF_SLUG / GITHUB_REF_SLUG_URL
|
||||
|
||||
Slug the environment variable **GITHUB_REF**
|
||||
@@ -94,6 +99,15 @@ The commit SHA that triggered the workflow
|
||||
| ---------------------------------------- | ---------------- |
|
||||
| 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
|
||||
|
||||
In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>\_SLUG** as subdomain to be compliant.
|
||||
@@ -103,15 +117,15 @@ In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>\_SLUG
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v2.x
|
||||
uses: rlespinasse/github-slug-action@v3.x
|
||||
|
||||
- name: Deploy dummy application using slug in the 'subdomain' part
|
||||
run: |
|
||||
./deploy-application.sh --url "https://${{ env.<GITHUB_VARIABLE>_SLUG_URL }}.staging.app.mycompagny.com"
|
||||
./deploy-application.sh --url "https://${{ env.<GITHUB_VARIABLE>_SLUG_URL }}.staging.app.mycompany.com"
|
||||
|
||||
- name: Deploy dummy application using slug in the 'resource path' part
|
||||
run: |
|
||||
./deploy-application.sh --url "https://staging.app.mycompagny.com/${{ env.<GITHUB_VARIABLE>_SLUG }}"
|
||||
./deploy-application.sh --url "https://staging.app.mycompany.com/${{ env.<GITHUB_VARIABLE>_SLUG }}"
|
||||
```
|
||||
|
||||
## Contribute
|
||||
@@ -129,9 +143,17 @@ 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'
|
||||
```
|
||||
|
||||
Use the current branch `v2.x` or a version tag (see [releases pages][6]).
|
||||
Please, use the current branch `v3.x` or a version tag (see [releases pages][6]) in order to fix your workflow.
|
||||
|
||||
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 don't exists anymore.
|
||||
>
|
||||
> 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
|
||||
|
||||
- [Mettre en place une CI/CD Angular avec GitHub Actions & Netlify][15] (in french :fr:)
|
||||
- [Github Actions : enfin des pipelines accessibles aux développeurs][16] (in french :fr:)
|
||||
- The next one is you. _Don't hesitate to add you to this list._
|
||||
|
||||
[1]: https://github.com/rlespinasse/github-slug-action/workflows/Build/badge.svg
|
||||
[2]: https://github.com/rlespinasse/github-slug-action/actions
|
||||
@@ -141,4 +163,11 @@ The master branch EOL is set on **2020-10-25** after a 6-month deprecation perio
|
||||
[6]: https://github.com/rlespinasse/github-slug-action/releases
|
||||
[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
|
||||
[9]: https://github.com/search?o=desc&q=rlespinasse%2Frlespinasse/github-slug-action+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code
|
||||
[9]: https://github.com/search?o=desc&q=rlespinasse/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
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|---------|--------|--------------------|
|
||||
| 3.x | v3.x | :white_check_mark: |
|
||||
| 2.x | v2.x | :white_check_mark: |
|
||||
| 1.1.x | v1.1.x | :white_check_mark: |
|
||||
| < 1.0.x | master | :x: |
|
||||
| 1.1.x | v1.1.x | :x: |
|
||||
| < 1.x | | :x: |
|
||||
|
||||
A GitHub repository can used one of the available branches as action inside its workflows.
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
name: "GitHub Slug"
|
||||
description: "Action to slug and expose some github variables"
|
||||
name: "GitHub Slug Action"
|
||||
description: "GitHub Action to expose slug value of environment variables inside your GitHub workflow"
|
||||
author: 'rlespinasse'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
branding:
|
||||
icon: "crop"
|
||||
color: "orange"
|
||||
icon: "minimize"
|
||||
color: "blue"
|
||||
|
||||
4
dist/index.js
vendored
4
dist/index.js
vendored
@@ -116,6 +116,7 @@ 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 {
|
||||
@@ -126,6 +127,9 @@ function run() {
|
||||
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);
|
||||
|
||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
2725
package-lock.json
generated
2725
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@@ -31,19 +31,19 @@
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "5.0.1",
|
||||
"@semantic-release/git": "9.0.0",
|
||||
"@types/jest": "^26.0.10",
|
||||
"@types/node": "^14.6.0",
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^14.14.3",
|
||||
"@typescript-eslint/parser": "^3.9.1",
|
||||
"@vercel/ncc": "^0.23.0",
|
||||
"eslint": "^7.5.0",
|
||||
"eslint": "^7.12.0",
|
||||
"eslint-plugin-github": "^4.1.1",
|
||||
"eslint-plugin-jest": "^23.20.0",
|
||||
"jest": "^26.4.2",
|
||||
"jest-circus": "^26.4.1",
|
||||
"jest": "^26.6.1",
|
||||
"jest-circus": "^26.6.1",
|
||||
"js-yaml": "^3.14.0",
|
||||
"prettier": "2.0.5",
|
||||
"semantic-release": "17.0.7",
|
||||
"ts-jest": "^26.3.0",
|
||||
"semantic-release": "17.2.3",
|
||||
"ts-jest": "^26.4.2",
|
||||
"typescript": "^3.9.7"
|
||||
},
|
||||
"release": {
|
||||
@@ -56,8 +56,8 @@
|
||||
"@semantic-release/github"
|
||||
],
|
||||
"branches": [
|
||||
"v1.1.x",
|
||||
"v2.x"
|
||||
"v2.x",
|
||||
"v3.x"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ 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 {
|
||||
@@ -38,6 +40,11 @@ async function run(): Promise<void> {
|
||||
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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user