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 | |
|---|---|---|---|
|
|
fbf6d7b9c7 | ||
|
|
c9eec68e1a | ||
|
|
242e04c2d2 | ||
|
|
6c69465e62 | ||
|
|
32aab7b8b1 |
3
.github/FUNDING.yml
vendored
3
.github/FUNDING.yml
vendored
@@ -1,3 +0,0 @@
|
|||||||
# These are supported funding model platforms
|
|
||||||
|
|
||||||
github: rlespinasse
|
|
||||||
3
.github/actions/bats/Dockerfile
vendored
Normal file
3
.github/actions/bats/Dockerfile
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
FROM bats/bats:latest
|
||||||
|
|
||||||
|
CMD ["./tests"]
|
||||||
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@@ -5,9 +5,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- uses: docker://ffurrer/bats:latest
|
- uses: ./.github/actions/bats
|
||||||
with:
|
|
||||||
args: "--recursive ."
|
|
||||||
- uses: cycjimmy/semantic-release-action@v2
|
- uses: cycjimmy/semantic-release-action@v2
|
||||||
with:
|
with:
|
||||||
semantic_version: 17.0.7
|
semantic_version: 17.0.7
|
||||||
@@ -30,16 +28,8 @@ jobs:
|
|||||||
- name: Output
|
- name: Output
|
||||||
run: |
|
run: |
|
||||||
echo "Slug variables"
|
echo "Slug variables"
|
||||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
|
|
||||||
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 "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 "Short SHA variables"
|
||||||
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||||
|
|||||||
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,20 +1,27 @@
|
|||||||
# [2.2.0](http://github.com/rlespinasse/github-slug-action/compare/2.1.1...2.2.0) (2021-04-05)
|
# [1.2.0](http://github.com/rlespinasse/github-slug-action/compare/1.1.1...1.2.0) (2021-04-05)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add version warning ([f536765](http://github.com/rlespinasse/github-slug-action/commit/f536765da448783f587c88e2c69f8f65b4e06541))
|
* add deprecation warning ([c9eec68](http://github.com/rlespinasse/github-slug-action/commit/c9eec68e1a02f91b77e9b978ad23527085244aaa))
|
||||||
|
|
||||||
## [2.1.1](http://github.com/rlespinasse/github-slug-action/compare/2.1.0...2.1.1) (2020-10-07)
|
## [1.1.1](http://github.com/rlespinasse/github-slug-action/compare/1.1.0...1.1.1) (2020-10-07)
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* remove set-env due to CVE fix ([d678898](http://github.com/rlespinasse/github-slug-action/commit/d678898ce55139d0005c35618747506fbeb2d1ed))
|
* remove set-env due to CVE fix ([6c69465](http://github.com/rlespinasse/github-slug-action/commit/6c69465e62a6430b5742c5bc0fce732f55630ee7))
|
||||||
|
|
||||||
# [2.1.0](http://github.com/rlespinasse/github-slug-action/compare/2.0.0...2.1.0) (2020-07-28)
|
# [1.1.0](http://github.com/rlespinasse/github-slug-action/compare/1.0.2...1.1.0) (2019-11-11)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* expose slug variables for github.event.ref ([5a334a8](http://github.com/rlespinasse/github-slug-action/commit/5a334a8573fc27451af5b2a6ee175d8e11579e10))
|
* **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)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* manage branch with slash properly ([c35fd20](http://github.com/rlespinasse/github-slug-action/commit/c35fd2094f6f0cb6c4858cf6db020eedd535671d))
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
|
# Container image that runs your code
|
||||||
FROM alpine:3.10
|
FROM alpine:3.10
|
||||||
RUN apk add --no-cache jq
|
|
||||||
|
# Copies your code file from your action repository to the filesystem path `/` of the container
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
# Code file to execute when the docker container starts up (`entrypoint.sh`)
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2019-2020 Romain Lespinasse
|
Copyright (c) 2019 Romain Lespinasse
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
143
README.md
143
README.md
@@ -1,88 +1,53 @@
|
|||||||
# GitHub Slug action
|
# GitHub Slug action
|
||||||
|
|
||||||
[![Actions Status][1]][2]
|
[](https://github.com/rlespinasse/github-slug-action/actions)
|
||||||
[![Public workflows that use this action.][8]][9]
|
|
||||||
|
|
||||||
This action slug and expose some github variables.
|
This action slug and expose some github variables.
|
||||||
|
|
||||||
`Slug` a variable will
|
`Slug` a variable will
|
||||||
|
|
||||||
- put the variable content in lower case
|
- put the variable content in lower case,
|
||||||
- replace any character by `-` except `0-9`, `a-z`, and `.`
|
- replace any character by `-` except `0-9` and `a-z`,
|
||||||
- remove leading and trailing `-` character
|
- remove leading and trailing `-` character,
|
||||||
- limit the string size to 63 characters
|
- limit the string size to 63 characters.
|
||||||
|
|
||||||
Others `Slug`-ish commands are available:
|
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.
|
||||||
- `Short SHA` a variable will limit the string size to 8 characters
|
|
||||||
|
|
||||||
## Exposed environment variables
|
## Exposed environment variables
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Inject slug/short variables
|
- uses: rlespinasse/github-slug-action@v1.1.x
|
||||||
uses: rlespinasse/github-slug-action@v2.x
|
- name: Print slug variables
|
||||||
|
|
||||||
- name: Print slug/short variables
|
|
||||||
run: |
|
run: |
|
||||||
echo "Slug variables"
|
echo ${{ env.GITHUB_REF_SLUG }}
|
||||||
echo " ref : ${{ env.GITHUB_REF_SLUG }}"
|
echo ${{ env.GITHUB_HEAD_REF_SLUG }}
|
||||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
echo ${{ env.GITHUB_BASE_REF_SLUG }}
|
||||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
echo ${{ env.GITHUB_SHA_SHORT }}
|
||||||
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 "Short SHA variables"
|
|
||||||
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Read [default environment variables][3] page for more information.
|
Read [default environment variables](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables) page for more information.
|
||||||
|
|
||||||
### GITHUB_REF_SLUG / GITHUB_REF_SLUG_URL
|
### GITHUB_REF_SLUG
|
||||||
|
|
||||||
Slug the environment variable **GITHUB_REF**
|
Slug the environment variable **GITHUB_REF**
|
||||||
|
|
||||||
The branch or tag ref that triggered the workflow.
|
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._
|
_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 |
|
| Environment variable (GITHUB_REF) | Slug variable (GITHUB_REF_SLUG) |
|
||||||
| ------------------------------ | ------------------- | ------------------- |
|
|-----------------------------------|---------------------------------|
|
||||||
| refs/heads/master | master | master |
|
| refs/heads/master | master |
|
||||||
| refs/heads/feat/new_feature | feat-new-feature | feat-new-feature |
|
| refs/heads/feat/new_feature | feat-new-feature |
|
||||||
| refs/tags/v1.0.0 | v1.0.0 | v1-0-0 |
|
| refs/tags/v1.0.0 | v1-0-0 |
|
||||||
| refs/tags/product@1.0.0-rc.2 | product-1.0.0-rc.2 | product-1-0-0-rc-2 |
|
| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 |
|
||||||
| refs/heads/New_Awesome_Product | new-awesome-product | new-awesome-product |
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
> **NOTE :**
|
|
||||||
> GITHUB_REF_SLUG_URL is design to be used as subdomain in an URL.
|
|
||||||
|
|
||||||
_Additional variables (only set for forked repositories) :_
|
_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_HEAD_REF_SLUG` : 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_BASE_REF_SLUG` : The branch of the base repository **GITHUB_BASE_REF**.
|
||||||
|
|
||||||
_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_REPOSITORY_SLUG_URL is design to be used as subdomain in an URL.
|
|
||||||
|
|
||||||
### GITHUB_SHA_SHORT
|
### GITHUB_SHA_SHORT
|
||||||
|
|
||||||
@@ -90,64 +55,6 @@ Short the environment variable **GITHUB_SHA**
|
|||||||
|
|
||||||
The commit SHA that triggered the workflow
|
The commit SHA that triggered the workflow
|
||||||
|
|
||||||
| GITHUB_SHA | GITHUB_SHA_SHORT |
|
| Environment variable (GITHUB_SHA) | Short variable (GITHUB_SHA_SHORT) |
|
||||||
| ---------------------------------------- | ---------------- |
|
|------------------------------------------|-----------------------------------|
|
||||||
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
| 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.
|
|
||||||
|
|
||||||
> **NOTE :**
|
|
||||||
> <GITHUB*VARIABLE>\_SLUG can be used in an URL only as part of the \_resource path*.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- name: Inject slug/short variables
|
|
||||||
uses: rlespinasse/github-slug-action@v2.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"
|
|
||||||
|
|
||||||
- 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 }}"
|
|
||||||
```
|
|
||||||
|
|
||||||
## 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
|
|
||||||
|
|
||||||
|
|||||||
13
SECURITY.md
13
SECURITY.md
@@ -1,14 +1,11 @@
|
|||||||
# Security Policy
|
# Security Policy
|
||||||
|
|
||||||
## Supported Versions and Branches
|
## Supported Versions
|
||||||
|
|
||||||
| Version | Branch | Supported |
|
| Version | Supported |
|
||||||
|---------|--------|--------------------|
|
|---------|--------------------|
|
||||||
| 2.x | v2.x | :white_check_mark: |
|
| 1.1.x | :white_check_mark: |
|
||||||
| 1.1.x | v1.1.x | :white_check_mark: |
|
| < 1.0.x | :x: |
|
||||||
| < 1.0.x | master | :x: |
|
|
||||||
|
|
||||||
A GitHub repository can used one of the available branches as action inside its workflows.
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,6 @@
|
|||||||
#!/bin/sh -l
|
#!/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() {
|
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" |
|
echo "$1" |
|
||||||
tr "[:upper:]" "[:lower:]" |
|
tr "[:upper:]" "[:lower:]" |
|
||||||
sed -r 's#refs/[^\/]*/##;s/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
sed -r 's#refs/[^\/]*/##;s/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
||||||
@@ -33,24 +12,11 @@ short_sha() {
|
|||||||
cut -c1-8
|
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_REF_SLUG=$(slug_ref "$GITHUB_REF")"
|
||||||
echo "GITHUB_HEAD_REF_SLUG=$(slug_ref "$GITHUB_HEAD_REF")"
|
echo "GITHUB_HEAD_REF_SLUG=$(slug_ref "$GITHUB_HEAD_REF")"
|
||||||
echo "GITHUB_BASE_REF_SLUG=$(slug_ref "$GITHUB_BASE_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")"
|
echo "GITHUB_SHA_SHORT=$(short_sha "$GITHUB_SHA")"
|
||||||
} >>"$GITHUB_ENV"
|
} >>"$GITHUB_ENV"
|
||||||
|
|
||||||
echo "::warning ::This version only support linux-based workflow, please use 'rlespinasse/github-slug-action@v3.x' instead"
|
echo "::warning ::This version is deprecated, please use 'rlespinasse/github-slug-action@v3.x' instead"
|
||||||
|
|||||||
1309
package-lock.json
generated
1309
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "docker run -w /workdir -v $(pwd):/workdir ffurrer/bats:latest --recursive .",
|
"test": "docker run -w /workdir -v $(pwd):/workdir bats/bats:latest ./tests",
|
||||||
"release": "semantic-release"
|
"release": "semantic-release"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
@test "short_sha: long hash" {
|
@test "Short long hash" {
|
||||||
test_short_sha \
|
test_short_sha \
|
||||||
"a35a1a486a260cfd99c5b6f8c6034a2929ba9b3f" \
|
"a35a1a486a260cfd99c5b6f8c6034a2929ba9b3f" \
|
||||||
"a35a1a48"
|
"a35a1a48"
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
#!/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}" ]
|
|
||||||
}
|
|
||||||
@@ -1,43 +1,43 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
@test "slug_ref:: master branch" {
|
@test "Slug master branch" {
|
||||||
test_slug_ref \
|
test_sluf_ref \
|
||||||
"refs/heads/master" \
|
"refs/heads/master" \
|
||||||
"master"
|
"master"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "slug_ref: a feature branch" {
|
@test "Slug a feature branch" {
|
||||||
test_slug_ref \
|
test_sluf_ref \
|
||||||
"refs/heads/feat/new_feature" \
|
"refs/heads/feat/new_feature" \
|
||||||
"feat-new-feature"
|
"feat-new-feature"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "slug_ref: a fix branch" {
|
@test "Slug a fix branch" {
|
||||||
test_slug_ref \
|
test_sluf_ref \
|
||||||
"refs/heads/fix/issue_number" \
|
"refs/heads/fix/issue_number" \
|
||||||
"fix-issue-number"
|
"fix-issue-number"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "slug_ref: a simple tag" {
|
@test "Slug a simple tag" {
|
||||||
test_slug_ref \
|
test_sluf_ref \
|
||||||
"refs/tags/v1.0.0" \
|
"refs/tags/v1.0.0" \
|
||||||
"v1.0.0"
|
"v1-0-0"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "slug_ref: a complex tag" {
|
@test "Slug a complex tag" {
|
||||||
test_slug_ref \
|
test_sluf_ref \
|
||||||
"refs/tags/product@1.0.0-rc.2" \
|
"refs/tags/product@1.0.0-rc.2" \
|
||||||
"product-1.0.0-rc.2"
|
"product-1-0-0-rc-2"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "slug_ref: a reference with upper case letters" {
|
@test "Slug a reference with upper case letters" {
|
||||||
test_slug_ref \
|
test_sluf_ref \
|
||||||
"refs/heads/New_Awesome_Product" \
|
"refs/heads/New_Awesome_Product" \
|
||||||
"new-awesome-product"
|
"new-awesome-product"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "slug_ref: a very long name" {
|
@test "Slug a very long name" {
|
||||||
test_slug_ref \
|
test_sluf_ref \
|
||||||
"refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters" \
|
"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"
|
"an-awesome-feature-very-very-very-very-very-very-very-long-more"
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
# Load sluf_ref function
|
# Load sluf_ref function
|
||||||
source entrypoint.sh > /dev/null 2>&1
|
source entrypoint.sh > /dev/null 2>&1
|
||||||
|
|
||||||
test_slug_ref() {
|
test_sluf_ref() {
|
||||||
given="${1}"
|
given="${1}"
|
||||||
expected="${2}"
|
expected="${2}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
#!/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}" ]
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
#!/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}" ]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user