Skip to content

Commit 0b0842f

Browse files
authored
Fixups to commit message checks to only happen during PR pushes (#509)
Handles bugs from #508. Also try and fix a quoting issues.
1 parent d2aa3a6 commit 0b0842f

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/devcontainer.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@ jobs:
2929

3030
- name: Get commit messages
3131
id: get-commit-messages
32+
if: github.event_name == 'pull_request'
3233
run: |
3334
# Only look at the last 10 commits, to avoid getting too much data.
3435
# If the message wasn't in there (e.g. because the push was a merge and too large), then we just ignore it.
3536
git fetch --deepen=10
36-
git log --format="%B" -10 ${{ github.event.before }}..${{ github.event.after }} > /tmp/commit_messages.txt || true
37-
echo "COMMIT_MESSAGES=$(cat /tmp/commit_messages.txt)" >> $GITHUB_OUTPUT
37+
# Handle multiline output:
38+
{
39+
echo 'COMMIT_MESSAGES<<COMMIT_MESSAGES_EOF'
40+
git log --format="%B" -10 ${{ github.event.before }}..${{ github.event.after }} | tee /tmp/commit_messages.txt
41+
echo COMMIT_MESSAGES_EOF
42+
} >> $GITHUB_OUTPUT
3843
3944
- name: Set NO_CACHE variable based on commit messages and for nightly builds
4045
if: github.event_name == 'schedule' || contains(steps.get-commit-messages.outputs.COMMIT_MESSAGES, 'NO_CACHE=true')
@@ -46,6 +51,9 @@ jobs:
4651
set -x
4752
printenv
4853
echo "NO_CACHE: ${NO_CACHE:-}"
54+
echo "EVENT_NAME: ${{ github.event_name }}"
55+
echo "BEFORE: ${{ github.event.before }}"
56+
echo "AFTER: ${{ github.event.after }}"
4957
echo "COMMIT_MESSAGES: ${{ steps.get-commit-messages.outputs.COMMIT_MESSAGES }}"
5058
echo "COMMIT_SHA: ${{ github.sha }}"
5159
echo "git log -1 ${{ github.sha }}: $(git log -1 ${{ github.sha }})"

0 commit comments

Comments
 (0)