Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rlespinasse/github-slug-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.0
Choose a base ref
...
head repository: rlespinasse/github-slug-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.1.0
Choose a head ref
  • 7 commits
  • 9 files changed
  • 2 contributors

Commits on Apr 26, 2020

  1. docs: fix typo

    rlespinasse committed Apr 26, 2020
    Copy the full SHA
    e5b7d5b View commit details

Commits on May 1, 2020

  1. Copy the full SHA
    7c65a05 View commit details

Commits on Jul 15, 2020

  1. Copy the full SHA
    498f51b View commit details

Commits on Jul 17, 2020

  1. Copy the full SHA
    9225a8a View commit details

Commits on Jul 20, 2020

  1. docs: add funding file

    rlespinasse authored Jul 20, 2020
    Copy the full SHA
    4268cc0 View commit details

Commits on Jul 28, 2020

  1. Copy the full SHA
    5a334a8 View commit details
  2. Copy the full SHA
    1172ed1 View commit details
Showing with 642 additions and 775 deletions.
  1. +3 −0 .github/FUNDING.yml
  2. +3 −2 .github/workflows/ci.yml
  3. +2 −9 CHANGELOG.md
  4. +1 −5 Dockerfile
  5. +1 −1 LICENSE
  6. +36 −19 README.md
  7. +8 −0 entrypoint.sh
  8. +579 −726 package-lock.json
  9. +9 −13 package.json
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: rlespinasse
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
11 changes: 2 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# [1.1.0](http://github.com/rlespinasse/github-slug-action/compare/1.0.2...1.1.0) (2019-11-11)
# [2.1.0](http://github.com/rlespinasse/github-slug-action/compare/2.0.0...2.1.0) (2020-07-28)


### 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)


### Bug Fixes

* manage branch with slash properly ([c35fd20](http://github.com/rlespinasse/github-slug-action/commit/c35fd2094f6f0cb6c4858cf6db020eedd535671d))
* expose slug variables for github.event.ref ([5a334a8](http://github.com/rlespinasse/github-slug-action/commit/5a334a8573fc27451af5b2a6ee175d8e11579e10))
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
55 changes: 36 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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]

This action slug and expose some github variables.

@@ -25,30 +25,32 @@ 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**
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 +65,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 +90,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 +112,14 @@ 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

When using this action on Windows or Macos, this error is display `##[error]Container action is only supported on Linux`.
Currently, this action don't support a system other than Linux due to Github Action Limitation.

[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
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -33,15 +33,23 @@ short_sha() {
cut -c1-8
}

get_event_keyvalue() {
if [ -f "$GITHUB_EVENT_PATH" ]; then
jq -r ".$1" "$GITHUB_EVENT_PATH" | grep -v "null"
fi
}

echo ::set-env name=GITHUB_REPOSITORY_SLUG::"$(slug "$GITHUB_REPOSITORY")"
echo ::set-env name=GITHUB_REPOSITORY_SLUG_URL::"$(slug_url "$GITHUB_REPOSITORY")"

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_EVENT_REF_SLUG::"$(slug_ref "$(get_event_keyvalue "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_EVENT_REF_SLUG_URL::"$(slug_url_ref "$(get_event_keyvalue "ref")")"

echo ::set-env name=GITHUB_SHA_SHORT::"$(short_sha "$GITHUB_SHA")"
Loading