Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-actions/github/env/title: Add action #1011

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 }}