From 6ce1decbbd626c22e73510a20e94a8112d99848d Mon Sep 17 00:00:00 2001 From: romain lespinasse Date: Wed, 6 Nov 2019 01:05:03 +0100 Subject: [PATCH] feat: expose GITHUB_REF_SLUG --- Dockerfile | 8 ++++++++ README.md | 21 +++++++++++++++++++++ action.yml | 6 ++++++ entrypoint.sh | 3 +++ 4 files changed, 38 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fa0188a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +# 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 +COPY entrypoint.sh /entrypoint.sh + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..a556bd3 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# GitHub Slug action + +This action slug and expose some github variables. + +`Slug` a variable will + +- put the variable content in lower case, +- replace any caracter by `-` except `0-9` and `a-z`, +- limit the string size to 63 caracter + +## Environement Variables + +### `GITHUB_REF_SLUG` + +Slug from `GITHUB_REF` env variables + +## Example usage + +```yaml +uses: rlespinasse/github-slug-action@master +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..81560a4 --- /dev/null +++ b/action.yml @@ -0,0 +1,6 @@ +# action.yml +name: 'GitHub Slug' +description: 'Action to slug and expose some github variables' +runs: + using: 'docker' + image: 'Dockerfile' \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..a533ecb --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh -l + +echo ::set-env name=GITHUB_REF_SLUG::$(echo $GITHUB_REF | tr A-Z a-z | sed -r 's#refs/.*/##;s/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g' | cut -c1-63)