Skip to content

Commit 23d2244

Browse files
committed
build: Fetch commit message from GitHub api
1 parent d206c25 commit 23d2244

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/build.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
14-
with:
15-
fetch-depth: 2
1614

1715
- uses: actions/setup-node@v3
1816
with:
@@ -25,11 +23,27 @@ jobs:
2523
# Build and output webpack stats to artifacts/webpack-stats.json
2624
- run: npm run build --if-present
2725

26+
# Read pull request commit message
27+
- name: Read pull request commit message
28+
id: pull-request-commit-message
29+
run: |
30+
# Get the pull request commit's SHA/ID from the event data file
31+
COMMIT_SHA=$(cat $GITHUB_EVENT_PATH | jq -r ".pull_request.head.sha")
32+
33+
# Fetch commit data from the GitHub API and pick the commit message value
34+
COMMIT_MESSAGE=$(gh api /repos/$GITHUB_REPOSITORY/commits/$COMMIT_SHA --jq .commit.message)
35+
36+
# Set output
37+
echo "commit-message=$COMMIT_MESSAGE" > $GITHUB_OUTPUT
38+
env:
39+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
2841
# Send webpack stats and build information to RelativeCI
2942
- name: Send webpack stats to RelativeCI
3043
uses: relative-ci/agent-action@v3.0.0-beta
3144
with:
3245
webpackStatsFile: ./artifacts/webpack-stats.json
3346
key: ${{ secrets.RELATIVE_CI_KEY }}
34-
token: ${{ secrets.GITHUB_TOKEN }}
35-
debug: true
47+
debug: true
48+
env:
49+
RELATIVE_CI_COMMIT_MESSAGE: steps.pull-request-commit-message.outputs.commit-message

0 commit comments

Comments
 (0)