Skip to content

Commit

Permalink
feat: support GHES step output management
Browse files Browse the repository at this point in the history
  • Loading branch information
rlespinasse authored Oct 31, 2022
1 parent b011e83 commit a362e5f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
44 changes: 31 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@ runs:
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
INPUT_SHORT_LENGTH: ${{ inputs.short-length }}

- uses: rlespinasse/slugify-value@v1.3.3
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_REPOSITORY
value: ${{ github.repository }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.3.3
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.3.3
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_HEAD_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.3.3
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_BASE_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}

# Specific values
- uses: rlespinasse/slugify-value@v1.3.3
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_EVENT_REF
value: ${{ github.event.ref }}
Expand All @@ -58,41 +58,59 @@ runs:

# Calculated values
- id: get-github-ref-name
run: echo "github-ref-name=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_OUTPUT"
run: |
refname="${{ github.head_ref || github.ref_name }}"
if [ -f "$GITHUB_OUTPUT" ]; then
echo "github-ref-name=${refname}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=github-ref-name::${refname}"
fi
shell: bash
- uses: rlespinasse/slugify-value@v1.3.3
- uses: rlespinasse/slugify-value@v1.4.0
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"
run: |
ownerpart=$(echo $GITHUB_REPOSITORY | cut -d/ -f1)
if [ -f "$GITHUB_OUTPUT" ]; then
echo "github-repository-owner-part=${ownerpart}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=github-repository-owner-part::${ownerpart}"
fi
shell: bash
- uses: rlespinasse/slugify-value@v1.3.3
- uses: rlespinasse/slugify-value@v1.4.0
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"
run: |
namepart=$(echo $GITHUB_REPOSITORY | cut -d/ -f2)
if [ -f "$GITHUB_OUTPUT" ]; then
echo "github-repository-name-part=${namepart}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=github-repository-name-part::${namepart}"
fi
shell: bash
- uses: rlespinasse/slugify-value@v1.3.3
- uses: rlespinasse/slugify-value@v1.4.0
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.5.1
- uses: rlespinasse/shortify-git-revision@v1.6.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.5.1
- uses: rlespinasse/shortify-git-revision@v1.6.0
with:
name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
revision: ${{ github.event.pull_request.head.sha }}
Expand Down
6 changes: 5 additions & 1 deletion preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ else
fi
fi
echo "::debug ::Set PREFLIGHT_SHORT_LENGTH=$PREFLIGHT_SHORT_LENGTH"
echo "PREFLIGHT_SHORT_LENGTH=$PREFLIGHT_SHORT_LENGTH" >> "$GITHUB_OUTPUT"
if [ -f "$GITHUB_OUTPUT" ]; then
echo "PREFLIGHT_SHORT_LENGTH=${PREFLIGHT_SHORT_LENGTH}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=PREFLIGHT_SHORT_LENGTH::${PREFLIGHT_SHORT_LENGTH}"
fi

0 comments on commit a362e5f

Please sign in to comment.