Last active
January 25, 2023 17:57
-
-
Save adrienjoly/747aba1ccc4b5626254359b19d14bb5c to your computer and use it in GitHub Desktop.
This script extracts the first line from stdin, then escapes single quotes, so it can be safely passed as an argument.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script extracts the first line from stdin, | |
# then escapes single quotes, so it can be safely passed as an argument. | |
# get first line from stdin | |
FIRST_LINE=$(cat - | head -1) | |
# escape single quotes | |
echo "${FIRST_LINE}" | sed -e "s/'/'\\\\''/g" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./escape_single_quotes_from_first_line.sh << EOF | |
'first' "line" | |
second line | |
third line | |
EOF | |
# => should return: '\''first'\'' "line" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jobs: | |
dummy: | |
steps: | |
- name: Get Commit Message | |
run: | | |
FIRST_LINE=$(git log --format=%B -n 1 ${{ github.event.after }} | ./escape_single_quotes_from_first_line.sh) | |
echo "message=${FIRST_LINE}" >> $GITHUB_OUTPUT | |
id: extract_message | |
- name: Pass To Mycommand | |
run: ./mycommand --message '${{ steps.extract_message.outputs.message }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment