-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description Adds the `/ready` slash ops command, which - fails if at least one item in the check list is still open - removes the check list from the PR body if all items are checked. Fixes #11 # Verification Manually verified in this PR.
- Loading branch information
Showing
5 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
name: Execute ChatOps command | ||
name: Execute ChatOps help command | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
|
46 changes: 46 additions & 0 deletions
46
.github/workflows/default_slash_ops_command_ready_callable.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
name: Execute ChatOps ready command | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
# USE_WORKFLOW | ||
workflow_call: | ||
# /USE_WORKFLOW | ||
# USE_REPOSITORY | ||
# repository_dispatch: | ||
# types: | ||
# - ready-command | ||
# /USE_REPOSITORY | ||
|
||
jobs: | ||
ready-command: | ||
name: "ChatOps: /ready" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
||
- name: Create comment | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: | | ||
// get the PR text and make sure that all items are checked | ||
const prText = context.payload.pull_request.body; | ||
prText.split('\n').forEach(line => { | ||
if (line.startsWith('- [ ]')) { | ||
throw new Error('Please check all items in the checklist before marking the PR as ready! Unchecked item: ' + line); | ||
} | ||
}); | ||
// remove the checklist paragraph from "# Checklist" to the end of the PR text | ||
const prTextWithoutChecklist = prText.split('\n').slice(0, prText.split('\n'). | ||
findIndex(line => line.startsWith('# Checklist'))).join('\n'); | ||
github.rest.pulls.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.issue.number, | ||
body: prTextWithoutChecklist, | ||
}); | ||
// set the PR to ready --> this is not possible with the GitHub API, use GraphQL instead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ jobs: | |
reactions: true | ||
commands: | | ||
help | ||
ready |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
name: Execute ChatOps command | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
repository_dispatch: | ||
types: | ||
- ready-command | ||
|
||
jobs: | ||
default: | ||
uses: Hapag-Lloyd/Workflow-Templates/.github/workflows/default_slash_ops_command_ready_callable.yml@main | ||
secrets: inherit |