Skip to content

Commit

Permalink
fix: use the correct variable to expose body message
Browse files Browse the repository at this point in the history
  • Loading branch information
rlespinasse committed Mar 17, 2021
1 parent f554bec commit a7039b1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 14 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,48 @@ jobs:
@semantic-release/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

os-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v2
- uses: ./
- name: Output
run: |
echo "Get author info"
echo " - ${{ env.GIT_COMMIT_AUTHOR }}"
echo " - ${{ env.GIT_COMMIT_AUTHOR_NAME }}"
echo " - ${{ env.GIT_COMMIT_AUTHOR_EMAIL }}"
echo "Get committer info"
echo " - ${{ env.GIT_COMMIT_COMMITTER }}"
echo " - ${{ env.GIT_COMMIT_COMMITTER_NAME }}"
echo " - ${{ env.GIT_COMMIT_COMMITTER_EMAIL }}"
echo "Get message info"
echo " - ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}"
echo " - ${{ env.GIT_COMMIT_MESSAGE_SUBJECT_SANITIZED }}"
echo " - ${{ env.GIT_COMMIT_MESSAGE_BODY }}"
win-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: ./
- name: Output
run: |
echo "Get author info"
echo " - $env:GIT_COMMIT_AUTHOR"
echo " - $env:GIT_COMMIT_AUTHOR_NAME"
echo " - $env:GIT_COMMIT_AUTHOR_EMAIL"
echo "Get committer info"
echo " - $env:GIT_COMMIT_COMMITTER"
echo " - $env:GIT_COMMIT_COMMITTER_NAME"
echo " - $env:GIT_COMMIT_COMMITTER_EMAIL"
echo "Get message info"
echo " - $env:GIT_COMMIT_MESSAGE_SUBJECT"
echo " - $env:GIT_COMMIT_MESSAGE_SUBJECT_SANITIZED"
echo " - $env:GIT_COMMIT_MESSAGE_BODY"
22 changes: 12 additions & 10 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh -l
#!/bin/bash

TEMPLATE_AUTHOR_FORMAT="%an <%ae>"
TEMPLATE_AUTHOR_NAME_FORMAT="%an"
Expand All @@ -19,15 +19,17 @@ git_log_format() {
}

{
echo "GIT_COMMIT_AUTHOR=$(git_log_format "$TEMPLATE_AUTHOR_FORMAT" "HEAD")"
echo "GIT_COMMIT_AUTHOR_NAME=$(git_log_format "$TEMPLATE_AUTHOR_NAME_FORMAT" "HEAD")"
echo "GIT_COMMIT_AUTHOR_EMAIL=$(git_log_format "$TEMPLATE_AUTHOR_EMAIL_FORMAT" "HEAD")"
echo "GIT_COMMIT_AUTHOR=$(git_log_format "${TEMPLATE_AUTHOR_FORMAT}" "HEAD")"
echo "GIT_COMMIT_AUTHOR_NAME=$(git_log_format "${TEMPLATE_AUTHOR_NAME_FORMAT}" "HEAD")"
echo "GIT_COMMIT_AUTHOR_EMAIL=$(git_log_format "${TEMPLATE_AUTHOR_EMAIL_FORMAT}" "HEAD")"

echo "GIT_COMMIT_COMMITTER=$(git_log_format "$TEMPLATE_COMMITTER_FORMAT" "HEAD")"
echo "GIT_COMMIT_COMMITTER_NAME=$(git_log_format "$TEMPLATE_COMMITTER_NAME_FORMAT" "HEAD")"
echo "GIT_COMMIT_COMMITTER_EMAIL=$(git_log_format "$TEMPLATE_COMMITTER_EMAIL_FORMAT" "HEAD")"
echo "GIT_COMMIT_COMMITTER=$(git_log_format "${TEMPLATE_COMMITTER_FORMAT}" "HEAD")"
echo "GIT_COMMIT_COMMITTER_NAME=$(git_log_format "${TEMPLATE_COMMITTER_NAME_FORMAT}" "HEAD")"
echo "GIT_COMMIT_COMMITTER_EMAIL=$(git_log_format "${TEMPLATE_COMMITTER_EMAIL_FORMAT}" "HEAD")"

echo "GIT_COMMIT_MESSAGE_SUBJECT=$(git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_FORMAT" "HEAD")"
echo "GIT_COMMIT_MESSAGE_SUBJECT_SANITIZED=$(git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_SANITIZED_FORMAT" "HEAD")"
echo "GIT_COMMIT_MESSAGE_BODY_BODY="$(git_log_format "$TEMPLATE_COMMIT_MESSAGE_BODY_FORMAT" "HEAD")""
echo "GIT_COMMIT_MESSAGE_SUBJECT=$(git_log_format "${TEMPLATE_COMMIT_MESSAGE_SUBJECT_FORMAT}" "HEAD")"
echo "GIT_COMMIT_MESSAGE_SUBJECT_SANITIZED=$(git_log_format "${TEMPLATE_COMMIT_MESSAGE_SUBJECT_SANITIZED_FORMAT}" "HEAD")"
echo 'GIT_COMMIT_MESSAGE_BODY<<EOF'
git_log_format "${TEMPLATE_COMMIT_MESSAGE_BODY_FORMAT}" "HEAD"
echo 'EOF'
} >>"$GITHUB_ENV"
17 changes: 13 additions & 4 deletions tests/git_log_format.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

apk add --no-cache git > /dev/null

TEST_COMMIT_SHA=9f2cc79
TEST_COMMIT_SHA=f554bec

# Load git_log_format function
source entrypoint.sh > /dev/null 2>&1
Expand Down Expand Up @@ -32,15 +32,24 @@ source entrypoint.sh > /dev/null 2>&1
}

@test "git_log_format: message subject" {
test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_FORMAT" "build: prepare github action"
test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_FORMAT" "ci: create a commit with multiple lines"
}

@test "git_log_format: message subject sanitized" {
test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_SANITIZED_FORMAT" "build-prepare-github-action"
test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_SANITIZED_FORMAT" "ci-create-a-commit-with-multiple-lines"
}

@test "git_log_format: message body" {
test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_BODY_FORMAT" ""
BODY=$(cat <<-END
Line 1
Line 2
Line 3
Line 4
Bottom line
END
)
test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_BODY_FORMAT" "$BODY"
}

test_git_log_format() {
Expand Down

0 comments on commit a7039b1

Please sign in to comment.