feat: support prefix on exported variables

This commit is contained in:
rlespinasse
2021-12-09 22:21:35 +01:00
committed by Romain Lespinasse
parent e13c7fcc34
commit e91720375f

View File

@@ -4,6 +4,11 @@ author: "Romain Lespinasse"
branding: branding:
icon: "minimize" icon: "minimize"
color: "blue" color: "blue"
inputs:
prefix:
description: "Value to prepend to each generated variable"
default: ""
required: false
runs: runs:
using: "composite" using: "composite"
steps: steps:
@@ -11,21 +16,26 @@ runs:
with: with:
key: GITHUB_REPOSITORY key: GITHUB_REPOSITORY
value: ${{ github.repository }} value: ${{ github.repository }}
prefix: ${{ inputs.prefix }}
- uses: rlespinasse/slugify-value@v1.1.0 - uses: rlespinasse/slugify-value@v1.1.0
with: with:
key: GITHUB_REF key: GITHUB_REF
prefix: ${{ inputs.prefix }}
- uses: rlespinasse/slugify-value@v1.1.0 - uses: rlespinasse/slugify-value@v1.1.0
with: with:
key: GITHUB_HEAD_REF key: GITHUB_HEAD_REF
prefix: ${{ inputs.prefix }}
- uses: rlespinasse/slugify-value@v1.1.0 - uses: rlespinasse/slugify-value@v1.1.0
with: with:
key: GITHUB_BASE_REF key: GITHUB_BASE_REF
prefix: ${{ inputs.prefix }}
# Specific values # Specific values
- uses: rlespinasse/slugify-value@v1.1.0 - uses: rlespinasse/slugify-value@v1.1.0
with: with:
key: GITHUB_EVENT_REF key: GITHUB_EVENT_REF
value: ${{ github.event.ref }} value: ${{ github.event.ref }}
prefix: ${{ inputs.prefix }}
# Calculated values # Calculated values
- id: get-github-ref-name - id: get-github-ref-name
@@ -35,6 +45,7 @@ runs:
with: with:
key: GITHUB_REF_NAME key: GITHUB_REF_NAME
value: ${{ steps.get-github-ref-name.outputs.github-ref-name }} value: ${{ steps.get-github-ref-name.outputs.github-ref-name }}
prefix: ${{ inputs.prefix }}
- id: get-github-repository-owner-part - id: get-github-repository-owner-part
run: echo "::set-output name=github-repository-owner-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f1)" run: echo "::set-output name=github-repository-owner-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f1)"
shell: bash shell: bash
@@ -42,6 +53,7 @@ runs:
with: with:
key: GITHUB_REPOSITORY_OWNER_PART key: GITHUB_REPOSITORY_OWNER_PART
value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }} value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }}
prefix: ${{ inputs.prefix }}
- id: get-github-repository-name-part - id: get-github-repository-name-part
run: echo "::set-output name=github-repository-name-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f2)" run: echo "::set-output name=github-repository-name-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f2)"
shell: bash shell: bash
@@ -49,14 +61,17 @@ runs:
with: with:
key: GITHUB_REPOSITORY_NAME_PART key: GITHUB_REPOSITORY_NAME_PART
value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }} value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }}
prefix: ${{ inputs.prefix }}
# Short # Short
- uses: rlespinasse/shortify-git-revision@v1.2.0 - uses: rlespinasse/shortify-git-revision@v1.2.0
with: with:
name: GITHUB_SHA name: GITHUB_SHA
continue-on-error: true continue-on-error: true
prefix: ${{ inputs.prefix }}
- uses: rlespinasse/shortify-git-revision@v1.2.0 - uses: rlespinasse/shortify-git-revision@v1.2.0
with: with:
name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
revision: ${{ github.event.pull_request.head.sha }} revision: ${{ github.event.pull_request.head.sha }}
continue-on-error: true continue-on-error: true
prefix: ${{ inputs.prefix }}