Compare commits

..

15 Commits
2.0.0 ... 2.1.1

Author SHA1 Message Date
semantic-release-bot
72cfc4cb1f chore(release): 2.1.1 [skip ci]
## [2.1.1](http://github.com/rlespinasse/github-slug-action/compare/2.1.0...2.1.1) (2020-10-07)

### Bug Fixes

* remove set-env due to CVE fix ([d678898](d678898ce5))
2020-10-07 20:54:07 +00:00
rlespinasse
d678898ce5 fix: remove set-env due to CVE fix 2020-10-07 22:53:24 +02:00
Romain Lespinasse
f527ed6e85 docs: add reference to the v3.x branch 2020-09-26 09:12:06 +02:00
dependabot[bot]
6efa53ebca build(deps): bump node-fetch from 2.6.0 to 2.6.1
Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/bitinn/node-fetch/compare/v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-12 17:41:09 +02:00
Romain Lespinasse
c0eae81222 style: use markdown syntax on link with image 2020-08-28 15:21:44 +02:00
Antoine Méausoone
7e9b2916a8 docs: add badge with number of public users 2020-08-26 19:20:17 +02:00
Romain Lespinasse
c34e0866d5 docs: improve troubleshooting section 2020-08-25 12:38:58 +02:00
rlespinasse
9ed3b31f8a ci: update release dependencies 2020-08-16 21:06:07 +02:00
semantic-release-bot
1172ed1802 chore(release): 2.1.0 [skip ci]
# [2.1.0](http://github.com/rlespinasse/github-slug-action/compare/2.0.0...2.1.0) (2020-07-28)

### Features

* expose slug variables for github.event.ref ([5a334a8](5a334a8573))
2020-07-28 16:50:05 +00:00
rlespinasse
5a334a8573 feat: expose slug variables for github.event.ref 2020-07-28 18:49:15 +02:00
Romain Lespinasse
4268cc0475 docs: add funding file 2020-07-20 20:26:41 +02:00
Romain Lespinasse
9225a8adaf docs: add troubleshooting section 2020-07-17 22:31:08 +02:00
rlespinasse
498f51bdf6 chore: update package json for security reason 2020-07-15 23:35:55 +02:00
rlespinasse
7c65a057e0 ci: improve release process 2020-05-01 17:18:08 +02:00
rlespinasse
e5b7d5b5fc docs: fix typo 2020-04-26 02:25:09 +02:00
9 changed files with 689 additions and 814 deletions

3
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,3 @@
# These are supported funding model platforms
github: rlespinasse

View File

@@ -10,13 +10,14 @@ jobs:
args: "--recursive ."
- uses: cycjimmy/semantic-release-action@v2
with:
semantic_version: 17.0.7
branches: |
[
'v1.1.x',
'v2.x'
]
extra_plugins: |
@semantic-release/git
@semantic-release/changelog
@semantic-release/changelog@5.0.1
@semantic-release/git@9.0.0
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

View File

@@ -1,13 +1,13 @@
# [1.1.0](http://github.com/rlespinasse/github-slug-action/compare/1.0.2...1.1.0) (2019-11-11)
### Features
* **short_sha:** add a shortened sha commit id ([d77acd4](http://github.com/rlespinasse/github-slug-action/commit/d77acd4f478b6971e0f7b2c9d1d4e721032bc5ab))
## [1.0.2](http://github.com/rlespinasse/github-slug-action/compare/1.0.1...1.0.2) (2019-11-06)
## [2.1.1](http://github.com/rlespinasse/github-slug-action/compare/2.1.0...2.1.1) (2020-10-07)
### Bug Fixes
* manage branch with slash properly ([c35fd20](http://github.com/rlespinasse/github-slug-action/commit/c35fd2094f6f0cb6c4858cf6db020eedd535671d))
* remove set-env due to CVE fix ([d678898](http://github.com/rlespinasse/github-slug-action/commit/d678898ce55139d0005c35618747506fbeb2d1ed))
# [2.1.0](http://github.com/rlespinasse/github-slug-action/compare/2.0.0...2.1.0) (2020-07-28)
### Features
* expose slug variables for github.event.ref ([5a334a8](http://github.com/rlespinasse/github-slug-action/commit/5a334a8573fc27451af5b2a6ee175d8e11579e10))

View File

@@ -1,8 +1,4 @@
# Container image that runs your code
FROM alpine:3.10
# Copies your code file from your action repository to the filesystem path `/` of the container
RUN apk add --no-cache jq
COPY entrypoint.sh /entrypoint.sh
# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Romain Lespinasse
Copyright (c) 2019-2020 Romain Lespinasse
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,6 +1,7 @@
# GitHub Slug action
[![Actions Status](https://github.com/rlespinasse/github-slug-action/workflows/Build/badge.svg)](https://github.com/rlespinasse/github-slug-action/actions)
[![Actions Status][1]][2]
[![Public workflows that use this action.][8]][9]
This action slug and expose some github variables.
@@ -25,22 +26,24 @@ Others `Slug`-ish commands are available:
- name: Print slug/short variables
run: |
echo "Slug variables"
echo " - ${{ env.GITHUB_REF_SLUG }}"
echo " - ${{ env.GITHUB_HEAD_REF_SLUG }}"
echo " - ${{ env.GITHUB_BASE_REF_SLUG }}"
echo " - ${{ 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 " - ${{ env.GITHUB_REF_SLUG_URL }}"
echo " - ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
echo " - ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
echo " - ${{ 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 " - ${{ env.GITHUB_SHA_SHORT }}"
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
```
Read [default environment variables](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables) page for more information.
Read [default environment variables][3] page for more information.
### GITHUB_REF_SLUG(_URL)
### GITHUB_REF_SLUG / GITHUB_REF_SLUG_URL
Slug the environment variable **GITHUB_REF**
@@ -48,7 +51,7 @@ The branch or tag ref that triggered the workflow.
_If neither a branch or tag is available for the event type, the variable will not exist._
| GITHUB_REF | GITHUB_REF_SLUG | GITHUB_REF_SLUG_URL |
|--------------------------------|---------------------|---------------------|
| ------------------------------ | ------------------- | ------------------- |
| refs/heads/master | master | master |
| refs/heads/feat/new_feature | feat-new-feature | feat-new-feature |
| refs/tags/v1.0.0 | v1.0.0 | v1-0-0 |
@@ -63,19 +66,23 @@ _Additional variables (only set for forked repositories) :_
- `GITHUB_HEAD_REF_SLUG`/`GITHUB_HEAD_REF_SLUG_URL`, The branch of the head repository **GITHUB_HEAD_REF**
- `GITHUB_BASE_REF_SLUG`/`GITHUB_BASE_REF_SLUG_URL`, The branch of the base repository **GITHUB_BASE_REF**
### GITHUB_REPOSITORY_SLUG
_Additional variables (only set for [create][4], and [delete][5] webhook events with `ref` data) :_
- `GITHUB_EVENT_REF_SLUG`/`GITHUB_EVENT_REF_SLUG_URL`, The git reference resource associated to the webhook.
### GITHUB_REPOSITORY_SLUG / GITHUB_REPOSITORY_SLUG_URL
Slug the environment variable **GITHUB_REPOSITORY**
The owner and repository name.
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG | GITHUB_REPOSITORY_SLUG_URL |
|----------------------------|----------------------------|----------------------------|
| -------------------------- | -------------------------- | -------------------------- |
| octocat/Hello-World | octocat-hello-world | octocat-hello-world |
| rlespinasse/Hello-World.go | rlespinasse-hello-world.go | rlespinasse-hello-world-go |
> **NOTE :**
> GITHUB_REF_SLUG_URL is design to be used as subdomain in an URL.
> GITHUB_REPOSITORY_SLUG_URL is design to be used as subdomain in an URL.
### GITHUB_SHA_SHORT
@@ -84,15 +91,15 @@ Short the environment variable **GITHUB_SHA**
The commit SHA that triggered the workflow
| GITHUB_SHA | GITHUB_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.
In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>\_SLUG** as subdomain to be compliant.
> **NOTE :**
> <GITHUB_VARIABLE>_SLUG can be used in an URL only as part of the _resource path_.
> <GITHUB*VARIABLE>\_SLUG can be used in an URL only as part of the \_resource path*.
```yaml
- name: Inject slug/short variables
@@ -106,3 +113,41 @@ In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>_SLUG*
run: |
./deploy-application.sh --url "https://staging.app.mycompagny.com/${{ env.<GITHUB_VARIABLE>_SLUG }}"
```
## Troubleshooting
### Missing master branch
If your workflow fail on the `Set up job` task with this kind of log :
```
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]).
The master branch EOL is set on **2020-10-25** after a 6-month deprecation period (more information on the [EOL issue][7])
### Can't run on Windows or Macos
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.
Currently, this action don't support a system other than Linux due to Github Action Limitation on `Container`-based action.
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
[2]: https://github.com/rlespinasse/github-slug-action/actions
[3]: https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
[4]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#create
[5]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delete
[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

View File

@@ -33,15 +33,22 @@ short_sha() {
cut -c1-8
}
echo ::set-env name=GITHUB_REPOSITORY_SLUG::"$(slug "$GITHUB_REPOSITORY")"
echo ::set-env name=GITHUB_REPOSITORY_SLUG_URL::"$(slug_url "$GITHUB_REPOSITORY")"
get_event_keyvalue() {
if [ -f "$GITHUB_EVENT_PATH" ]; then
jq -r ".$1" "$GITHUB_EVENT_PATH" | grep -v "null"
fi
}
echo ::set-env name=GITHUB_REF_SLUG::"$(slug_ref "$GITHUB_REF")"
echo ::set-env name=GITHUB_HEAD_REF_SLUG::"$(slug_ref "$GITHUB_HEAD_REF")"
echo ::set-env name=GITHUB_BASE_REF_SLUG::"$(slug_ref "$GITHUB_BASE_REF")"
echo ::set-env name=GITHUB_REF_SLUG_URL::"$(slug_url_ref "$GITHUB_REF")"
echo ::set-env name=GITHUB_HEAD_REF_SLUG_URL::"$(slug_url_ref "$GITHUB_HEAD_REF")"
echo ::set-env name=GITHUB_BASE_REF_SLUG_URL::"$(slug_url_ref "$GITHUB_BASE_REF")"
echo ::set-env name=GITHUB_SHA_SHORT::"$(short_sha "$GITHUB_SHA")"
{
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"

1335
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "github-slug-action",
"version": "1.1.0",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"test": "docker run -w /workdir -v $(pwd):/workdir ffurrer/bats:latest --recursive .",
@@ -11,9 +11,9 @@
"url": "http://github.com/rlespinasse/github-slug-action.git"
},
"devDependencies": {
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"semantic-release": "^17.0.7"
"@semantic-release/changelog": "5.0.1",
"@semantic-release/git": "9.0.0",
"semantic-release": "17.0.7"
},
"release": {
"tagFormat": "${version}",
@@ -21,16 +21,12 @@
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/git",
{
"assets": [
"package.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/git",
"@semantic-release/github"
],
"branches": [
"v1.1.x",
"v2.x"
]
}
}