Compare commits

..

25 Commits
3.0.0 ... 3.2.0

Author SHA1 Message Date
semantic-release-bot
c8d8ee50d0 chore(release): 3.2.0 [skip ci]
# [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](5b9fe6015d))
2021-01-12 09:23:14 +00:00
Julien Klaer
5b9fe6015d feat: expose GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT 2021-01-12 10:22:14 +01:00
rlespinasse
5629d21ee9 ci(linter): use repo eslint configuration 2021-01-09 09:44:25 +01:00
dependabot[bot]
b6938fb2bd build(deps): bump node-notifier from 8.0.0 to 8.0.1
Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/mikaelbr/node-notifier/releases)
- [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md)
- [Commits](https://github.com/mikaelbr/node-notifier/compare/v8.0.0...v8.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-01 18:42:36 +01:00
Romain Lespinasse
d6257a36a9 docs(contributing): fix typo 2020-12-18 17:39:27 +01:00
dependabot[bot]
7ad978282a build(deps): bump ini from 1.3.5 to 1.3.8
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-14 08:32:50 +01:00
Romain Lespinasse
9f5fafb8ad docs: add talks/articles section 2020-12-12 18:13:01 +01:00
Romain Lespinasse
750d2f7f48 ci: setup CodeQL GitHub workflow 2020-12-05 19:37:21 +01:00
Alain Hélaïli
2b1034b1fb docs: fix typo in sample 2020-12-05 15:27:19 +01:00
dependabot[bot]
1b1913be6c build(deps-dev): bump semantic-release from 17.0.7 to 17.2.3
Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 17.0.7 to 17.2.3.
- [Release notes](https://github.com/semantic-release/semantic-release/releases)
- [Commits](https://github.com/semantic-release/semantic-release/compare/v17.0.7...v17.2.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-19 12:59:57 +01:00
Romain Lespinasse
cc560ad7b4 ci: run linter on default branch 2020-11-01 21:31:23 +01:00
rlespinasse
549c11b4e2 ci: improve build workflow 2020-11-01 21:29:52 +01:00
rlespinasse
68eb43656c ci: add dependabot for github-actions 2020-11-01 21:29:52 +01:00
rlespinasse
2aba10a826 ci: add linter workflow 2020-11-01 21:29:52 +01:00
Romain Lespinasse
afcda09378 docs(readme): add license badge 2020-11-01 21:01:37 +01:00
Romain Lespinasse
15f6edebdd docs(readme): improve action scope 2020-11-01 20:52:34 +01:00
semantic-release-bot
e4699e49fc chore(release): 3.1.0 [skip ci]
# [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](3cddc4f12d))
2020-11-01 19:40:26 +00:00
Romain Lespinasse
3cddc4f12d feat(action): improve marketplace information 2020-11-01 20:39:24 +01:00
rlespinasse
d7817bf204 docs(contributing): improve issue links 2020-10-31 16:12:03 +01:00
Romain Lespinasse
4e3f956c5e docs: add contributing guide 2020-10-31 09:36:05 +01:00
Romain Lespinasse
f79727b5cc docs: improve master EOL section 2020-10-31 08:24:38 +01:00
Romain Lespinasse
a3c7c5c7a1 docs: use v3.x branch in example 2020-10-31 08:22:11 +01:00
rlespinasse
008aa6260d build: bump dev dependencies versions 2020-10-27 09:28:24 +01:00
rlespinasse
3c7ae42a01 ci: activate release on v3.x branch 2020-10-26 21:42:08 +01:00
Romain Lespinasse
ae2430ad57 docs(security): remove v1.1.x from supported versions 2020-10-26 21:29:58 +01:00
15 changed files with 959 additions and 2012 deletions

6
.dependabot/config.xml Normal file
View File

@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

View File

@@ -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'

View File

@@ -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
View 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
View 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/.*

View File

@@ -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
View 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=

View File

@@ -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

View File

@@ -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.

View File

@@ -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
View File

@@ -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

File diff suppressed because one or more lines are too long

2725
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -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"
]
}
}

View File

@@ -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)
)
}
}