Skip to content

Commit 090b81a

Browse files
committed
build: add slash commands via reusable workflows
1 parent c6800ab commit 090b81a

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed

.github/workflows/check_required_files.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ name: check_required_files
2121

2222
# Workflow triggers:
2323
on:
24-
# Trigger the workflow when a PR review is requested:
25-
pull_request_target:
26-
types: [review_requested]
24+
# Allow the workflow to be triggered by other workflows
25+
workflow_call:
2726

2827
# Global permissions:
2928
permissions:
@@ -66,31 +65,15 @@ jobs:
6665
lfs: false
6766
timeout-minutes: 10
6867

69-
# Check if the review is requested from the `stdlib-bot` user:
70-
- name: 'Check if review is requested from stdlib-bot'
71-
id: check-reviewers
72-
run: |
73-
# Get the list of reviewers:
74-
reviewers=$(jq -r '.pull_request.requested_reviewers | .[] | .login' "$GITHUB_EVENT_PATH")
75-
76-
# Check if the list of reviewers contains the `stdlib-bot` user:
77-
if [[ $reviewers == *"stdlib-bot"* ]]; then
78-
echo "is_stdlib_bot=true" >> $GITHUB_OUTPUT
79-
else
80-
echo "is_stdlib_bot=false" >> $GITHUB_OUTPUT
81-
fi
82-
8368
# Configure git:
8469
- name: 'Configure git'
85-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
8670
run: |
8771
git config --local user.email "noreply@stdlib.io"
8872
git config --local user.name "stdlib-bot"
8973
git fetch --all
9074
9175
# Get list of added files:
9276
- name: 'Get list of added files'
93-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
9477
id: added-files
9578
run: |
9679
page=1
@@ -108,7 +91,6 @@ jobs:
10891
10992
# Check whether the pull request contains a new `README.md` file; if not, exit with a non-zero exit code:
11093
- name: 'Exit if pull request does not contain a new README.md file'
111-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
11294
run: |
11395
if [[ ! "${{ steps.added-files.outputs.files }}" =~ "README.md" ]]; then
11496
echo "Pull request does not contain a new README.md file."
@@ -117,7 +99,6 @@ jobs:
11799
118100
# Check whether the pull request contains files which are required to be present for all packages:
119101
- name: 'Check whether the pull request contains files which are required to be present for all packages'
120-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
121102
id: check-required-files
122103
run: |
123104
# Define a list of required files:
@@ -218,7 +199,6 @@ jobs:
218199

219200
# Create a comment on the pull request informing the user whether the pull request is missing required files:
220201
- name: 'Create a comment on the pull request informing the user whether the pull request is missing required files'
221-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
222202
# Pin action to full length commit SHA
223203
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
224204
with:

.github/workflows/slash-commands.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2024 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Workflow name:
20+
name: slash-commands
21+
22+
# Workflow triggers:
23+
on:
24+
issue_comment:
25+
types: [created, edited]
26+
27+
# Workflow jobs:
28+
jobs:
29+
30+
# Define a job for checking for required files:
31+
check-files:
32+
33+
# Define the conditions under which the job should run:
34+
if: github.event.issue.pull_request && contains(github.event.comment.body, '/stdlib check-files')
35+
36+
# Run reusable workflow:
37+
uses: ./.github/workflows/check_required_files.yml

0 commit comments

Comments
 (0)