From e27069b315f64acabbe5003d6721ed98a07f82c4 Mon Sep 17 00:00:00 2001 From: Jack Plowman Date: Wed, 8 Jun 2022 09:48:16 +0100 Subject: [PATCH 1/5] Change template folder name --- .../task_pull_request_template.md | 0 .../test_pull_request_template.md | 0 .github/pull_request_template.md | 1 + .github/workflows/create-pull-request.yml | 33 ------------------- 4 files changed, 1 insertion(+), 33 deletions(-) rename .github/{pull-request-templates => PULL_REQUEST_TEMPLATE}/task_pull_request_template.md (100%) rename .github/{pull-request-templates => PULL_REQUEST_TEMPLATE}/test_pull_request_template.md (100%) create mode 100644 .github/pull_request_template.md delete mode 100644 .github/workflows/create-pull-request.yml diff --git a/.github/pull-request-templates/task_pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/task_pull_request_template.md similarity index 100% rename from .github/pull-request-templates/task_pull_request_template.md rename to .github/PULL_REQUEST_TEMPLATE/task_pull_request_template.md diff --git a/.github/pull-request-templates/test_pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/test_pull_request_template.md similarity index 100% rename from .github/pull-request-templates/test_pull_request_template.md rename to .github/PULL_REQUEST_TEMPLATE/test_pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..12d59f960 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1 @@ +Please don't change this description yet. The template will be added by a Github Action diff --git a/.github/workflows/create-pull-request.yml b/.github/workflows/create-pull-request.yml deleted file mode 100644 index 37af38cf9..000000000 --- a/.github/workflows/create-pull-request.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: "Create Pull Requests" -on: - push: - branches: - - "task/*" - - "test/*" - -jobs: - pull-request: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Get branch number - run: echo "BRANCH_NUMBER=$(echo ${{ github.ref_name }} | grep -Eo '[A-Za-z]{2,5}-[0-9]{1,5}')" >> $GITHUB_ENV - - name: Get branch designator - run: echo "BRANCH_DESIGNATOR=$(echo ${{ github.ref_name }} | sed 's|/.*||')" >> $GITHUB_ENV - - name: Render Pull Request template - id: template - uses: chuhlomin/render-template@v1.4 - with: - template: .github/pull-request-templates/${{ env.BRANCH_DESIGNATOR }}_pull_request_template.md - vars: | - BRANCH_NUMBER: ${{ env.BRANCH_NUMBER }} - BRANCH_DESIGNATOR: ${{ env.BRANCH_DESIGNATOR }} - - name: Create Pull Request - uses: repo-sync/pull-request@v2 - with: - destination_branch: "develop" - pr_title: "${{ github.ref_name }} into develop" - pr_body: ${{ steps.template.outputs.result }} - pr_draft: true - github_token: ${{ secrets.GITHUB_TOKEN }} From c022b5ec4ec65c92f70b809c9de43316ddb4de22 Mon Sep 17 00:00:00 2001 From: Jack Plowman Date: Wed, 8 Jun 2022 09:59:44 +0100 Subject: [PATCH 2/5] Add new workflow --- .github/pull_request_template.md | 4 ++- .../update-pull-request-with-template.yml | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update-pull-request-with-template.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 12d59f960..d54f7e838 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1 +1,3 @@ -Please don't change this description yet. The template will be added by a Github Action +# Warning + +Please don't change this description yet. The template will be added by a Github Action very shortly. diff --git a/.github/workflows/update-pull-request-with-template.yml b/.github/workflows/update-pull-request-with-template.yml new file mode 100644 index 000000000..6e6ee0cb3 --- /dev/null +++ b/.github/workflows/update-pull-request-with-template.yml @@ -0,0 +1,33 @@ +name: "Update Pull Request with Template" +on: + push: + branches: + - "task/*" + - "test/*" + +jobs: + update-pull-request: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Get branch number + run: echo "BRANCH_NUMBER=$(echo ${{ github.ref_name }} | grep -Eo '[A-Za-z]{2,5}-[0-9]{1,5}')" >> $GITHUB_ENV + - name: Get branch designator + run: echo "BRANCH_DESIGNATOR=$(echo ${{ github.ref_name }} | sed 's|/.*||')" >> $GITHUB_ENV + - name: Render Pull Request template + id: template + uses: chuhlomin/render-template@v1.4 + with: + template: .github/pull-request-templates/${{ env.BRANCH_DESIGNATOR }}_pull_request_template.md + vars: | + BRANCH_NUMBER: ${{ env.BRANCH_NUMBER }} + BRANCH_DESIGNATOR: ${{ env.BRANCH_DESIGNATOR }} + - uses: tzkhan/pr-update-action@v2 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + base-branch-regex: 'develop' + head-branch-regex: ' ${{ github.ref_name }}' + body-template: ${{ steps.template.outputs.result }} + body-update-action: 'suffix' + body-uppercase-base-match: false From 8e3491c132b1df4688a3ec8443c3b45e0a5e9787 Mon Sep 17 00:00:00 2001 From: Jack Plowman Date: Wed, 8 Jun 2022 10:01:58 +0100 Subject: [PATCH 3/5] Update Github Actions --- .github/workflows/code-quality.yml | 2 +- .github/workflows/update-pull-request-with-template.yml | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 442201fe5..22b826e62 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -3,7 +3,7 @@ on: push: branches: [develop, main] pull_request: - types: [opened, synchronize, reopened] + types: [opened, ready_for_review, synchronize, reopened] jobs: check-code-quality: runs-on: ubuntu-latest diff --git a/.github/workflows/update-pull-request-with-template.yml b/.github/workflows/update-pull-request-with-template.yml index 6e6ee0cb3..d0c190a78 100644 --- a/.github/workflows/update-pull-request-with-template.yml +++ b/.github/workflows/update-pull-request-with-template.yml @@ -1,9 +1,7 @@ name: "Update Pull Request with Template" on: - push: - branches: - - "task/*" - - "test/*" + pull_request: + types: [created] jobs: update-pull-request: From 095c5ffa0bf18260aa8f6c0354d579bbc92b8c70 Mon Sep 17 00:00:00 2001 From: Jack Plowman Date: Wed, 8 Jun 2022 10:04:38 +0100 Subject: [PATCH 4/5] Fix incorrect directory --- .github/pull_request_template.md | 10 +++++- .../update-pull-request-with-template.yml | 31 ------------------- 2 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 .github/workflows/update-pull-request-with-template.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d54f7e838..78a707c07 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,11 @@ # Warning -Please don't change this description yet. The template will be added by a Github Action very shortly. +Please update the url to include the template name. + +## To use the task template + +You must add this as a suffix to the url `?template=.github/PULL_REQUEST_TEMPLATE/task_pull_request_template.md` + +## To use the test template + +You must add this as a suffix to the url `?template=.github/PULL_REQUEST_TEMPLATE/test_pull_request_template.md` diff --git a/.github/workflows/update-pull-request-with-template.yml b/.github/workflows/update-pull-request-with-template.yml deleted file mode 100644 index d0c190a78..000000000 --- a/.github/workflows/update-pull-request-with-template.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: "Update Pull Request with Template" -on: - pull_request: - types: [created] - -jobs: - update-pull-request: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Get branch number - run: echo "BRANCH_NUMBER=$(echo ${{ github.ref_name }} | grep -Eo '[A-Za-z]{2,5}-[0-9]{1,5}')" >> $GITHUB_ENV - - name: Get branch designator - run: echo "BRANCH_DESIGNATOR=$(echo ${{ github.ref_name }} | sed 's|/.*||')" >> $GITHUB_ENV - - name: Render Pull Request template - id: template - uses: chuhlomin/render-template@v1.4 - with: - template: .github/pull-request-templates/${{ env.BRANCH_DESIGNATOR }}_pull_request_template.md - vars: | - BRANCH_NUMBER: ${{ env.BRANCH_NUMBER }} - BRANCH_DESIGNATOR: ${{ env.BRANCH_DESIGNATOR }} - - uses: tzkhan/pr-update-action@v2 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - base-branch-regex: 'develop' - head-branch-regex: ' ${{ github.ref_name }}' - body-template: ${{ steps.template.outputs.result }} - body-update-action: 'suffix' - body-uppercase-base-match: false From 11d8105c9bb30597c1e448ce9025695587dca65d Mon Sep 17 00:00:00 2001 From: Jack Plowman Date: Thu, 9 Jun 2022 11:20:23 +0100 Subject: [PATCH 5/5] Update PR template --- .github/pull_request_template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 78a707c07..4cfa2a21b 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,8 +4,8 @@ Please update the url to include the template name. ## To use the task template -You must add this as a suffix to the url `?template=.github/PULL_REQUEST_TEMPLATE/task_pull_request_template.md` +You must add this as a suffix to the url `?template=task_pull_request_template.md` ## To use the test template -You must add this as a suffix to the url `?template=.github/PULL_REQUEST_TEMPLATE/test_pull_request_template.md` +You must add this as a suffix to the url `?template=test_pull_request_template.md`