Skip to content

Commit 701fc9d

Browse files
committed
ci: update label_commands.yml to ensure skipped checks run while preserving behavior
1 parent c561e36 commit 701fc9d

File tree

2 files changed

+138
-117
lines changed

2 files changed

+138
-117
lines changed

.github/workflows/generate_pr_commit_message.yml

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#/
22
# @license Apache-2.0
33
#
4-
# Copyright (c) 2024 The Stdlib Authors.
4+
# Copyright (c) 2025 The Stdlib Authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -23,36 +23,36 @@ name: generate_pr_commit_message
2323
on:
2424
pull_request_target:
2525
types:
26+
- opened
27+
- edited
28+
- synchronize
2629
- labeled
2730

2831
# Global permissions:
2932
permissions:
3033
# Allow read-only access to the repository contents:
3134
contents: read
35+
# Allow writing to pull requests (e.g., for posting comments):
36+
pull-requests: write
3237

3338
# Workflow jobs:
3439
jobs:
35-
3640
# Job to generate commit message draft:
3741
generate-commit-message:
38-
3942
# Define a display name:
40-
name: 'Generate PR Commit Message Draft'
43+
name: "Generate PR Commit Message Draft"
4144

4245
# Define the type of virtual host machine:
4346
runs-on: ubuntu-latest
4447

45-
# Ensure the job only runs when the specified label is added:
46-
if: github.event.label.name == 'Ready to Merge'
47-
4848
# Define environment variables:
4949
env:
5050
PR_NUMBER: ${{ github.event.pull_request.number }}
5151

5252
# Define the sequence of job steps...
5353
steps:
5454
# Checkout repository:
55-
- name: 'Checkout repository'
55+
- name: "Checkout repository"
5656
# Pin action to full length commit SHA
5757
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5858
with:
@@ -62,28 +62,35 @@ jobs:
6262
.mailmap
6363
sparse-checkout-cone-mode: false
6464

65-
# Generate commit message:
66-
- name: 'Generate commit message'
65+
# Generate commit message or mark as successful:
66+
- name: "Generate commit message or mark as successful"
6767
id: commit_message
6868
run: |
69-
COMMIT_MESSAGE=$($GITHUB_WORKSPACE/.github/workflows/scripts/generate_pr_commit_message $PR_NUMBER)
70-
EXIT_CODE=$?
71-
72-
echo "commit_message<<EOF" >> $GITHUB_OUTPUT
73-
echo "$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
74-
echo "EOF" >> $GITHUB_OUTPUT
75-
76-
if [ $EXIT_CODE -eq 200 ]; then
77-
echo "has_tracking_issue=true" >> $GITHUB_OUTPUT
69+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'Ready to Merge') }}" == "true" ]]; then
70+
COMMIT_MESSAGE=$($GITHUB_WORKSPACE/.github/workflows/scripts/generate_pr_commit_message $PR_NUMBER)
71+
EXIT_CODE=$?
72+
73+
echo "commit_message<<EOF" >> $GITHUB_OUTPUT
74+
echo "$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
75+
echo "EOF" >> $GITHUB_OUTPUT
76+
77+
if [ $EXIT_CODE -eq 200 ]; then
78+
echo "has_tracking_issue=true" >> $GITHUB_OUTPUT
79+
else
80+
echo "has_tracking_issue=false" >> $GITHUB_OUTPUT
81+
fi
7882
else
83+
echo "Generated commit message draft successfully."
84+
echo "commit_message=Skipped due to missing 'Ready to Merge' label" >> $GITHUB_OUTPUT
7985
echo "has_tracking_issue=false" >> $GITHUB_OUTPUT
8086
fi
8187
8288
# Ensure the script itself doesn't fail the workflow:
8389
exit 0
8490
8591
# Post commit message as PR comment:
86-
- name: 'Post commit message as PR comment'
92+
- name: "Post commit message as PR comment"
93+
if: contains(github.event.pull_request.labels.*.name, 'Ready to Merge')
8794
# Pin action to full length commit SHA
8895
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
8996
with:
@@ -94,8 +101,3 @@ jobs:
94101
95102
```text
96103
${{ steps.commit_message.outputs.commit_message }}
97-
```
98-
99-
*Please review the above commit message and make any necessary adjustments.*
100-
101-
${{ steps.commit_message.outputs.has_tracking_issue == 'true' && '⚠️ **Action Required**: This PR references tracking issues. Please update the PR description to replace any "Closes", "Fixes", or "Resolves" keywords with "Ref" when referencing these issues.' || '' }}

0 commit comments

Comments
 (0)