From 9dd808d15a5a2c776105ef61bd3db2febd0f5dc5 Mon Sep 17 00:00:00 2001 From: kristianmills Date: Fri, 27 Jun 2025 14:07:34 -0700 Subject: [PATCH 1/8] fix: Test " in commit message --- README.md | 2 +- action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a00927..20facb2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CI](https://github.com/scribd/job-notification/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/scribd/job-notification/actions/workflows/test.yml) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) -A GitHub Action for sending job notifications +A GitHub Action for sending job notifications. ## Table of contents diff --git a/action.yml b/action.yml index 496a0a9..c632f15 100644 --- a/action.yml +++ b/action.yml @@ -30,7 +30,7 @@ runs: - name: Set fields env: input_message: ${{ inputs.message }} - commit_message: ${{ github.event.head_commit.message }} + commit_message: "test message" shell: bash if: always() id: fields From dc1231f3078ddf8e65b5f982d3bdff03f6e769d7 Mon Sep 17 00:00:00 2001 From: kristianmills Date: Mon, 30 Jun 2025 13:56:54 -0700 Subject: [PATCH 2/8] Test --- action.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index c632f15..8069f85 100644 --- a/action.yml +++ b/action.yml @@ -27,14 +27,26 @@ inputs: runs: using: composite steps: + - name: Set escaped env variables + id: env + shell: bash + run: | + { + echo "commit_message<> $GITHUB_ENV + { + echo "input_message<> $GITHUB_ENV - name: Set fields - env: - input_message: ${{ inputs.message }} - commit_message: "test message" shell: bash if: always() id: fields run: | + echo if [ "${{ inputs.status }}" = "success" ]; then echo "emoji=large_green_square" >> $GITHUB_OUTPUT echo "color=good" >> $GITHUB_OUTPUT @@ -60,7 +72,11 @@ runs: commit_message="Link to the latest commit in the repository" message="" fi - echo "message=$message" >> $GITHUB_OUTPUT + { + echo "message<> $GITHUB_OUTPUT author=${{ github.event.pusher.name }} # context from `push` trigger author=${author:-${{ github.event.sender.login }}} # context from `workflow_dispatch` trigger From 420d353e60244b66214bbafa40ef42046ba5b297 Mon Sep 17 00:00:00 2001 From: kristianmills Date: Mon, 30 Jun 2025 16:06:21 -0700 Subject: [PATCH 3/8] test toJSON --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 8069f85..d3c7aff 100644 --- a/action.yml +++ b/action.yml @@ -33,12 +33,12 @@ runs: run: | { echo "commit_message<> $GITHUB_ENV { echo "input_message<> $GITHUB_ENV - name: Set fields From ad1b55b555a8852d8f2ae0660a9bcf67127e1dcf Mon Sep 17 00:00:00 2001 From: kristianmills Date: Tue, 1 Jul 2025 12:00:48 -0700 Subject: [PATCH 4/8] Try suggestion --- action.yml | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/action.yml b/action.yml index d3c7aff..2dd8096 100644 --- a/action.yml +++ b/action.yml @@ -31,22 +31,14 @@ runs: id: env shell: bash run: | - { - echo "commit_message<> $GITHUB_ENV - { - echo "input_message<> $GITHUB_ENV + printf 'commit_message<> $GITHUB_ENV + printf 'input_message<> $GITHUB_ENV - name: Set fields shell: bash if: always() id: fields run: | - echo + echo "Made it here!" if [ "${{ inputs.status }}" = "success" ]; then echo "emoji=large_green_square" >> $GITHUB_OUTPUT echo "color=good" >> $GITHUB_OUTPUT @@ -61,17 +53,16 @@ runs: if [ ! -z "$input_message" ]; then message=$input_message elif [ ! -z "$commit_message" ]; then - # get commit message from `push` trigger - commit_message=$(echo "$commit_message" | head -n 1) - message="" + commit_msg_line=$(printf '%s\n' "$commit_message" | head -n 1) + message=$(printf '' "${{ inputs.repository }}" "${{ github.sha }}" "$commit_msg_line") elif git rev-parse --is-inside-git-dir > /dev/null 2>&1; then - # get commit message from the current git directory to support `workflow_dispatch` trigger - commit_message=$(git log --format=%B -n 1 | head -n 1) - message="" + commit_msg_line=$(git log --format=%B -n 1 | head -n 1) + message=$(printf '' "${{ inputs.repository }}" "${{ github.sha }}" "$commit_msg_line") else - commit_message="Link to the latest commit in the repository" - message="" + commit_msg_line="Link to the latest commit in the repository" + message=$(printf '' "${{ inputs.repository }}" "${{ github.sha }}" "$commit_msg_line") fi + { echo "message< Date: Tue, 1 Jul 2025 16:11:45 -0700 Subject: [PATCH 5/8] Test --- action.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 2dd8096..020bea7 100644 --- a/action.yml +++ b/action.yml @@ -27,16 +27,13 @@ inputs: runs: using: composite steps: - - name: Set escaped env variables - id: env - shell: bash - run: | - printf 'commit_message<> $GITHUB_ENV - printf 'input_message<> $GITHUB_ENV - name: Set fields shell: bash if: always() id: fields + env: + commit_message: ${{ github.event.head_commit.message }} + input_message: ${{ inputs.message }} run: | echo "Made it here!" if [ "${{ inputs.status }}" = "success" ]; then From de5d13adc34cd73a2daca1e3dd45bd0c1829e75d Mon Sep 17 00:00:00 2001 From: kristianmills Date: Tue, 1 Jul 2025 16:14:58 -0700 Subject: [PATCH 6/8] test --- README.md | 2 +- action.yml | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 20facb2..8a00927 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CI](https://github.com/scribd/job-notification/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/scribd/job-notification/actions/workflows/test.yml) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) -A GitHub Action for sending job notifications. +A GitHub Action for sending job notifications ## Table of contents diff --git a/action.yml b/action.yml index 020bea7..9af8563 100644 --- a/action.yml +++ b/action.yml @@ -28,14 +28,13 @@ runs: using: composite steps: - name: Set fields + env: + input_message: ${{ inputs.message }} + commit_message: ${{ github.event.head_commit.message }} shell: bash if: always() id: fields - env: - commit_message: ${{ github.event.head_commit.message }} - input_message: ${{ inputs.message }} run: | - echo "Made it here!" if [ "${{ inputs.status }}" = "success" ]; then echo "emoji=large_green_square" >> $GITHUB_OUTPUT echo "color=good" >> $GITHUB_OUTPUT @@ -59,12 +58,7 @@ runs: commit_msg_line="Link to the latest commit in the repository" message=$(printf '' "${{ inputs.repository }}" "${{ github.sha }}" "$commit_msg_line") fi - - { - echo "message<> $GITHUB_OUTPUT + echo "message=$message" >> $GITHUB_OUTPUT author=${{ github.event.pusher.name }} # context from `push` trigger author=${author:-${{ github.event.sender.login }}} # context from `workflow_dispatch` trigger From b84f3f6ddcf21012f797c9953f82f45d8617cf63 Mon Sep 17 00:00:00 2001 From: kristianmills Date: Tue, 1 Jul 2025 16:20:43 -0700 Subject: [PATCH 7/8] test --- action.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 9af8563..5cb4af9 100644 --- a/action.yml +++ b/action.yml @@ -49,11 +49,13 @@ runs: if [ ! -z "$input_message" ]; then message=$input_message elif [ ! -z "$commit_message" ]; then - commit_msg_line=$(printf '%s\n' "$commit_message" | head -n 1) - message=$(printf '' "${{ inputs.repository }}" "${{ github.sha }}" "$commit_msg_line") + # get commit message from `push` trigger + commit_message=$(echo "$commit_message" | head -n 1) + message="" elif git rev-parse --is-inside-git-dir > /dev/null 2>&1; then - commit_msg_line=$(git log --format=%B -n 1 | head -n 1) - message=$(printf '' "${{ inputs.repository }}" "${{ github.sha }}" "$commit_msg_line") + # get commit message from the current git directory to support `workflow_dispatch` trigger + commit_message=$(git log --format=%B -n 1 | head -n 1) + message="" else commit_msg_line="Link to the latest commit in the repository" message=$(printf '' "${{ inputs.repository }}" "${{ github.sha }}" "$commit_msg_line") From 1f7333786e884ad193c8a2760b53d388d7691bde Mon Sep 17 00:00:00 2001 From: kristianmills Date: Tue, 1 Jul 2025 16:25:13 -0700 Subject: [PATCH 8/8] test --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 5cb4af9..496a0a9 100644 --- a/action.yml +++ b/action.yml @@ -57,8 +57,8 @@ runs: commit_message=$(git log --format=%B -n 1 | head -n 1) message="" else - commit_msg_line="Link to the latest commit in the repository" - message=$(printf '' "${{ inputs.repository }}" "${{ github.sha }}" "$commit_msg_line") + commit_message="Link to the latest commit in the repository" + message="" fi echo "message=$message" >> $GITHUB_OUTPUT