From 92d55951aaf4a4cf18d5cc438d998e5ccf65d840 Mon Sep 17 00:00:00 2001 From: Michael Frikke Depner Date: Mon, 28 Aug 2023 12:54:41 +0200 Subject: [PATCH 1/5] Add PR template --- .github/pull_request_template.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..76d0e96c --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,7 @@ +# READ ME BEFORE SUBMITTING A PR + +Please do not submit a PR with your solution to the Gilded Rose Kata. This repo is intended to be used as a starting point for the kata. + +- [ ] I acknowledge that this PR is not a solution to the Gilded Rose Kata, but an improvement to the template. + +## Please provide your PR description below this line From dd201077ddca9466f427a88dd6f2a7c95832bc04 Mon Sep 17 00:00:00 2001 From: Michael Frikke Depner Date: Mon, 28 Aug 2023 12:55:24 +0200 Subject: [PATCH 2/5] Add PR validation workflow --- .github/workflows/pr-validation.yml | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/pr-validation.yml diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml new file mode 100644 index 00000000..990f09a9 --- /dev/null +++ b/.github/workflows/pr-validation.yml @@ -0,0 +1,34 @@ +name: "PR Tasks Completed Check" +on: + pull_request: + types: opened + +jobs: + task-check: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - name: Comment if checkmark is missing + if: ${{ !contains(github.event.pull_request.body, '[X] I acknowledge') }} + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: "Please don't submit a PR containing Kata solutions. If you are adding an improvement to the Katas repo, please resubmit this PR and check the `[X]` box in the PR template." + }) + - name: Close PR if checkmark is missing + if: ${{ !contains(github.event.pull_request.body, '[X] I acknowledge') }} + uses: actions/github-script@v6 + with: + script: | + github.rest.pulls.update({ + pull_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed' + }) From 188dbc66bafca3752f629d918a0c9c2f280d0f54 Mon Sep 17 00:00:00 2001 From: Michael Frikke Depner Date: Tue, 29 Aug 2023 13:02:29 +0200 Subject: [PATCH 3/5] Fix github script indentation --- .github/workflows/pr-validation.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 990f09a9..52bc2010 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -16,10 +16,10 @@ jobs: with: script: | github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: "Please don't submit a PR containing Kata solutions. If you are adding an improvement to the Katas repo, please resubmit this PR and check the `[X]` box in the PR template." + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: "Please don't submit a PR containing Kata solutions. If you are adding an improvement to the Katas repo, please resubmit this PR and check the `[X]` box in the PR template." }) - name: Close PR if checkmark is missing if: ${{ !contains(github.event.pull_request.body, '[X] I acknowledge') }} @@ -27,8 +27,8 @@ jobs: with: script: | github.rest.pulls.update({ - pull_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - state: 'closed' + pull_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed' }) From 63b8d1461ce87ef8d4e937563cc49165922765dc Mon Sep 17 00:00:00 2001 From: Michael Frikke Depner Date: Tue, 29 Aug 2023 13:05:34 +0200 Subject: [PATCH 4/5] Only run PR validation from base repository --- .github/workflows/pr-validation.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 52bc2010..9dc5d0be 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -5,6 +5,8 @@ on: jobs: task-check: + # Only run from the base repository + if: github.event.repository.name == 'emilybache/GildedRose-Refactoring-Kata' runs-on: ubuntu-latest permissions: issues: write From 0d4faad2ae1fba4bf974f83eb76307bdeda28352 Mon Sep 17 00:00:00 2001 From: Michael Frikke Depner Date: Tue, 29 Aug 2023 13:07:54 +0200 Subject: [PATCH 5/5] Change PR close comment --- .github/workflows/pr-validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 9dc5d0be..cc00c12e 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -21,7 +21,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: "Please don't submit a PR containing Kata solutions. If you are adding an improvement to the Katas repo, please resubmit this PR and check the `[X]` box in the PR template." + body: "Please don't submit a Pull Request containing a Kata solution to the original repo from Emily Bache. If you are instead trying to add an improvement, please resubmit this PR and check the `[X]` box in the PR template." }) - name: Close PR if checkmark is missing if: ${{ !contains(github.event.pull_request.body, '[X] I acknowledge') }}