Skip to content

Commit

Permalink
Lighthouse Fix: Access correct commit message for both merges and PRs (
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeigs committed Jun 20, 2024
1 parent 882d9fd commit cf7d48a
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,27 @@ jobs:
- name: Output commit timestamp
id: commit_timestamp_step
run: |
timestamp=$(git log -1 --format=%cd --date=iso-strict)
echo "::set-output name=commit_timestamp::$timestamp"
TIMESTAMP=$(git log -1 --format=%cd --date=iso-strict)
echo "COMMIT_TIMESTAMP=${TIMESTAMP}" >> $GITHUB_ENV
- name: Output commit message on the pull request
id: commit_message_step
run: |
response=$(curl --request GET --url 'https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits?page=1&per_page=1000' --header 'Accept: application/vnd.github.v3+json' --header 'Content-Type: application/json')
last_commit_message=$(echo "$response" | jq '.[-1].commit.message')
echo "::set-output name=last_commit_message::$last_commit_message"
if ${{ github.ref != 'refs/heads/main' }} == true; then
response=$(curl --request GET --url 'https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits?page=1&per_page=1000' --header 'Accept: application/vnd.github.v3+json' --header 'Content-Type: application/json')
last_commit_message=$(echo "$response" | jq '.[-1].commit.message')
echo "COMMIT_MESSAGE=$last_commit_message"
COMMIT_MESSAGE=$last_commit_message
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
else
FULL_MESSAGE="${{ github.event.head_commit.message }}"
FIRST_LINE=$(echo "$FULL_MESSAGE" | head -n 1)
echo "COMMIT_MESSAGE=${FIRST_LINE}" >> $GITHUB_ENV
fi
- name: Upload Lighthouse to MongoDB
uses: mongodb/docs-worker-actions/upload-lighthouse@main
env:
PROJECT_TO_BUILD: ${{ matrix.project }}
COMMIT_MESSAGE: ${{ fromJson(steps.commit_message_step.outputs.last_commit_message) }}
COMMIT_TIMESTAMP: ${{ steps.commit_timestamp_step.outputs.commit_timestamp }}
COMMIT_MESSAGE: ${{ env.COMMIT_MESSAGE }}
COMMIT_TIMESTAMP: ${{ env.COMMIT_TIMESTAMP }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
ATLAS_URI: ${{ secrets.ATLAS_URI }}

ATLAS_URI: ${{ secrets.ATLAS_URI }}

0 comments on commit cf7d48a

Please sign in to comment.