Files
github-slug-action/action.yml
Vin 00198f8992 fix: use environment file to manage outputs
Co-authored-by: Vin <vin@8sistemas.com>
Co-authored-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2022-10-15 20:56:22 +02:00

102 lines
3.5 KiB
YAML

name: "GitHub Slug Action"
description: "GitHub Action to expose slug value of environment variables inside your GitHub workflow"
author: "Romain Lespinasse"
branding:
icon: "minimize"
color: "blue"
inputs:
prefix:
description: "Value to prepend to each generated variable"
default: ""
required: false
slug-maxlength:
description: "Max length of the slugified values"
default: "63"
required: true
short-length:
description: "Length of the shortify values (git default if empty)"
required: false
runs:
using: "composite"
steps:
- run: $GITHUB_ACTION_PATH/preflight.sh
id: prefligth
shell: bash
env:
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
INPUT_SHORT_LENGTH: ${{ inputs.short-length }}
- uses: rlespinasse/slugify-value@v1.3.2
with:
key: GITHUB_REPOSITORY
value: ${{ github.repository }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.3.2
with:
key: GITHUB_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.3.2
with:
key: GITHUB_HEAD_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.3.2
with:
key: GITHUB_BASE_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
# Specific values
- uses: rlespinasse/slugify-value@v1.3.2
with:
key: GITHUB_EVENT_REF
value: ${{ github.event.ref }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
# Calculated values
- id: get-github-ref-name
run: echo "github-ref-name=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_OUTPUT"
shell: bash
- uses: rlespinasse/slugify-value@v1.3.2
with:
key: GITHUB_REF_NAME
value: ${{ steps.get-github-ref-name.outputs.github-ref-name }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- id: get-github-repository-owner-part
run: echo "github-repository-owner-part=$(echo $GITHUB_REPOSITORY | cut -d/ -f1)" >> "$GITHUB_OUTPUT"
shell: bash
- uses: rlespinasse/slugify-value@v1.3.2
with:
key: GITHUB_REPOSITORY_OWNER_PART
value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- id: get-github-repository-name-part
run: echo "github-repository-name-part=$(echo $GITHUB_REPOSITORY | cut -d/ -f2)" >> "$GITHUB_OUTPUT"
shell: bash
- uses: rlespinasse/slugify-value@v1.3.2
with:
key: GITHUB_REPOSITORY_NAME_PART
value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
# Short
- uses: rlespinasse/shortify-git-revision@v1.4.0
with:
name: GITHUB_SHA
short-on-error: true
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
prefix: ${{ inputs.prefix }}
- uses: rlespinasse/shortify-git-revision@v1.4.0
with:
name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
revision: ${{ github.event.pull_request.head.sha }}
short-on-error: true
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
prefix: ${{ inputs.prefix }}