Skip to content

Commit 5be9f03

Browse files
committed
Enhance approval gate workflow with commit SHA and message retrieval
- Added steps to the approval gate job to retrieve the commit SHA and message from the pull request, improving the workflow's ability to handle commit information effectively. - Updated the environment condition to ensure proper execution based on author association and event type.
1 parent ae59ec1 commit 5be9f03

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

.github/workflows/distroless-build-test-push-workflow.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,44 @@ on:
1515
- develop
1616
jobs:
1717
approval-gate:
18-
uses: ./.github/workflows/approval-gate.yml
18+
permissions:
19+
contents: read
20+
runs-on: ubuntu-latest
21+
outputs:
22+
commit-sha: ${{ steps.get-sha.outputs.commit_sha }}
23+
commit-message: ${{ steps.get-message.outputs.commit_message }}
24+
environment: ${{
25+
(github.event_name == 'pull_request_target' &&
26+
!contains(fromJSON('["MEMBER", "OWNER", "COLLABORATOR"]'), github.event.pull_request.author_association))
27+
&& inputs.environment-name
28+
|| (github.event_name == 'pull_request' && inputs.environment-name)
29+
|| ''
30+
}}
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v6
34+
with:
35+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
36+
- name: Get commit SHA
37+
id: get-sha
38+
run: |
39+
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
40+
echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
41+
echo "Commit SHA: ${COMMIT_SHA}"
42+
- name: Get commit message
43+
id: get-message
44+
run: |
45+
COMMIT_MSG=$(git log -1 --pretty=%B)
46+
echo "commit_message<<EOF" >> $GITHUB_OUTPUT
47+
echo "$COMMIT_MSG" >> $GITHUB_OUTPUT
48+
echo "EOF" >> $GITHUB_OUTPUT
49+
echo "Commit message:"
50+
echo "$COMMIT_MSG"
51+
- name: Approval status
52+
run: |
53+
echo "Event: ${{ github.event_name }}"
54+
echo "Author association: ${{ github.event.pull_request.author_association }}"
55+
echo "Approval granted or not required"
1956
check-formating:
2057
runs-on: ubuntu-latest
2158
needs: approval-gate

0 commit comments

Comments
 (0)