Skip to content

Commit

Permalink
script
Browse files Browse the repository at this point in the history
  • Loading branch information
kayman-mk committed Jan 9, 2025
1 parent c386d38 commit 3e441a3
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions .github/workflows/this_slash_ops_command_ready.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,38 @@ on:
- ready-command

jobs:
default:
uses: Hapag-Lloyd/Workflow-Templates/.github/workflows/default_slash_ops_command_ready_callable.yml@kayma/fix-ready
secrets: inherit
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
console.log(context);
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
// remove HTML comments
const cleanPrText = prText.split('\n').slice(0, prText.split('\n').
findIndex(line => line.startsWith('# Checklist'))).join('\n').
replace(/<!--[\s\S]*?-->/g, '');
// update the PR text
github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: cleanPrText,
});
// set the PR to ready --> this is not possible with the GitHub API, use GraphQL instead

0 comments on commit 3e441a3

Please sign in to comment.