Skip to content

Commit

Permalink
gh-actions/github/env/title: Add action (#1011)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax committed Nov 12, 2023
1 parent 6687c0b commit d21142d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 25 deletions.
32 changes: 7 additions & 25 deletions gh-actions/github/env/summary/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,14 @@ runs:
| {"title": ($message | split("\n")[0]),
"body": ($message | " > " + (split("\n")[1:] | join("\n > ")))}
- run: |
if [[ -n "$TITLE" ]]; then
printf 'title=%s' "${TITLE}" >> "$GITHUB_OUTPUT"
fi
if [[ -n "${{ inputs.link }}" ]]; then
REF_TITLE=(
"${{ ! inputs.pr && 'postsubmit' || 'pr' }}/"
"${{ inputs.pr && format('{0}/', inputs.pr) || '' }}"
"${{ inputs.target-branch }}"
"@${{ steps.sha-short.outputs.string }}")
else
REF_SHA_LINK="[${{ steps.sha-short.outputs.string }}](https://github.com/${{ github.repository }}/commit/${{ inputs.sha }})"
REF_TITLE=(
"${{ ! inputs.pr && 'postsubmit' || 'pr' }}/")
if [[ -n "${{ inputs.pr }}" ]]; then
REF_TITLE+=("[${{ inputs.pr }}](https://github.com/${{ github.repository }}/pull/${{ inputs.pr }})/")
fi
REF_TITLE+=(
"${{ inputs.target-branch }}"
"@${REF_SHA_LINK}")
fi
IFS=; echo "title=${REF_TITLE[*]}" >> "$GITHUB_OUTPUT"
shell: bash
- uses: envoyproxy/toolshed/gh-actions/github/env/title@6620a66a7fd17194fd7cdda83399c6bd7d837571
id: title
env:
TITLE: ${{ inputs.title }}
with:
link: ${{ inputs.link }}
pr: ${{ inputs.pr }}
sha: ${{ inputs.sha }}
target-branch: ${{ inputs.target-branch }}
title: ${{ inputs.title }}

- run: |
echo "link=$PR_LINK" >> $GITHUB_OUTPUT
Expand Down
55 changes: 55 additions & 0 deletions gh-actions/github/env/title/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
inputs:
link:
type: string
required: false
pr:
type: number
sha:
type: string
required: true
target-branch:
type: string
required: false
title:
type: string
required: false

outputs:
title:
value: ${{ steps.title.outputs.title }}


runs:
using: composite
steps:
- uses: envoyproxy/toolshed/gh-actions/str/sub@actions-v0.1.37
id: sha-short
with:
string: ${{ inputs.sha }}
length: 7
- run: |
if [[ -n "$TITLE" ]]; then
printf 'title=%s' "${TITLE}" >> "$GITHUB_OUTPUT"
fi
if [[ -n "${{ inputs.link }}" ]]; then
REF_TITLE=(
"${{ ! inputs.pr && 'postsubmit' || 'pr' }}/"
"${{ inputs.pr && format('{0}/', inputs.pr) || '' }}"
"${{ inputs.target-branch }}"
"@${{ steps.sha-short.outputs.string }}")
else
REF_SHA_LINK="[${{ steps.sha-short.outputs.string }}](https://github.com/${{ github.repository }}/commit/${{ inputs.sha }})"
REF_TITLE=(
"${{ ! inputs.pr && 'postsubmit' || 'pr' }}/")
if [[ -n "${{ inputs.pr }}" ]]; then
REF_TITLE+=("[${{ inputs.pr }}](https://github.com/${{ github.repository }}/pull/${{ inputs.pr }})/")
fi
REF_TITLE+=(
"${{ inputs.target-branch }}"
"@${REF_SHA_LINK}")
fi
IFS=; echo "title=${REF_TITLE[*]}" >> "$GITHUB_OUTPUT"
shell: bash
id: title
env:
TITLE: ${{ inputs.title }}

0 comments on commit d21142d

Please sign in to comment.