From 38c7d5ef024d68fe67fbccac7eb98cbc8a4b60ce Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Tue, 14 Mar 2023 19:51:11 +0100 Subject: [PATCH] Update workflows --- .../.github/workflows/codeql-analysis.yaml | 13 +------- .../.github/workflows/publish.yaml | 4 +-- .../.github/workflows/pull_request.yaml | 33 +++++++++++++++++++ .../.github/workflows/test.yaml | 23 ------------- 4 files changed, 36 insertions(+), 37 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/.github/workflows/pull_request.yaml diff --git a/{{cookiecutter.project_slug}}/.github/workflows/codeql-analysis.yaml b/{{cookiecutter.project_slug}}/.github/workflows/codeql-analysis.yaml index 14db408..20640ee 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/codeql-analysis.yaml +++ b/{{cookiecutter.project_slug}}/.github/workflows/codeql-analysis.yaml @@ -1,14 +1,3 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# name: "CodeQL" on: @@ -83,4 +72,4 @@ jobs: - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 with: - category: {% raw %}"/language:${{matrix.language}}"{% endraw %} + category: "/language:${{matrix.language}}" diff --git a/{{cookiecutter.project_slug}}/.github/workflows/publish.yaml b/{{cookiecutter.project_slug}}/.github/workflows/publish.yaml index f057ebd..217d4ff 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/publish.yaml +++ b/{{cookiecutter.project_slug}}/.github/workflows/publish.yaml @@ -1,4 +1,4 @@ -name: Build, publish & deploy +name: Test, build, publish & deploy on: workflow_dispatch: @@ -25,7 +25,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }}{% endraw %} - name: Build and push Docker image - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 with: context: . push: true diff --git a/{{cookiecutter.project_slug}}/.github/workflows/pull_request.yaml b/{{cookiecutter.project_slug}}/.github/workflows/pull_request.yaml new file mode 100644 index 0000000..d6f90f2 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/workflows/pull_request.yaml @@ -0,0 +1,33 @@ +name: Test & auto merge + +on: + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + tests: + uses: ./.github/workflows/test.yaml + auto_merge: + name: Auto merge + runs-on: ubuntu-latest + needs: tests + permissions: + pull-requests: write + contents: write + env: + GH_TOKEN: {% raw %}${{ github.token }}{% endraw %} + if: >- + github.event.pull_request + && github.event.pull_request.merged == false + && ( + github.event.pull_request.user.login == 'crocmagnon-pr[bot]' + || github.event.pull_request.user.login == 'pre-commit-ci[bot]' + ) + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Auto merge + run: gh pr merge {% raw %}${{github.event.pull_request.number}}{% endraw %} --delete-branch --rebase diff --git a/{{cookiecutter.project_slug}}/.github/workflows/test.yaml b/{{cookiecutter.project_slug}}/.github/workflows/test.yaml index e1468aa..5fdcd58 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/test.yaml +++ b/{{cookiecutter.project_slug}}/.github/workflows/test.yaml @@ -3,8 +3,6 @@ name: Test on: workflow_dispatch: workflow_call: - pull_request: - branches: [ "master" ] permissions: contents: read @@ -35,24 +33,3 @@ jobs: - name: Test run: pytest --cov=. --cov-branch --cov-report term-missing:skip-covered working-directory: ./src/ - auto_merge: - name: Auto merge - runs-on: ubuntu-latest - needs: tests - permissions: - pull-requests: write - contents: write - env: - GH_TOKEN: {% raw %}${{ github.token }}{% endraw %} - if: >- - github.event.pull_request - && github.event.pull_request.merged == false - && ( - github.event.pull_request.user.login == 'crocmagnon-pr[bot]' - || github.event.pull_request.user.login == 'pre-commit-ci[bot]' - ) - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Auto merge - run: gh pr merge {% raw %}${{github.event.pull_request.number}}{% endraw %} --delete-branch --rebase