From d2b461c927c108c499548876e9b2c75e42f9f728 Mon Sep 17 00:00:00 2001 From: Igor Date: Thu, 20 Mar 2025 12:01:54 +0100 Subject: [PATCH] GitHub config --- .../.github/dependabot.yml | 14 ++++- .../.github/workflows/ci.yml | 20 ++++++- .../.github/workflows/merge-pr.yaml | 59 +++++++++++++++++++ 3 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/.github/workflows/merge-pr.yaml diff --git a/{{cookiecutter.project_slug}}/.github/dependabot.yml b/{{cookiecutter.project_slug}}/.github/dependabot.yml index 45f35a28e..54d4d9a77 100644 --- a/{{cookiecutter.project_slug}}/.github/dependabot.yml +++ b/{{cookiecutter.project_slug}}/.github/dependabot.yml @@ -9,6 +9,8 @@ updates: # Every weekday schedule: interval: 'daily' + day: monday + time: '06:00' groups: github-actions: patterns: @@ -25,7 +27,9 @@ updates: - 'compose/production/django/' # Every weekday schedule: - interval: 'daily' + interval: 'weekly' + day: monday + time: '06:00' # Ignore minor version updates (3.10 -> 3.11) but update patch versions ignore: - dependency-name: '*' @@ -50,7 +54,9 @@ updates: {%- endif %} # Every weekday schedule: - interval: 'daily' + interval: 'weekly' + day: monday + time: '06:00' {%- endif %} @@ -61,7 +67,9 @@ updates: directory: '/' # Every weekday schedule: - interval: 'daily' + interval: 'weekly' + day: monday + time: '06:00' groups: python: update-types: diff --git a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml index 83625e481..6b0b92ab1 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml @@ -68,23 +68,37 @@ jobs: uses: actions/checkout@v4 {%- if cookiecutter.use_docker == 'y' %} + - name: Dummy .env file + run: touch .env + - name: Build the Stack run: docker compose -f docker-compose.local.yml build django - - name: Build the docs - run: docker compose -f docker-compose.docs.yml build docs - - name: Check DB Migrations run: docker compose -f docker-compose.local.yml run --rm django python manage.py makemigrations --check - name: Run DB Migrations run: docker compose -f docker-compose.local.yml run --rm django python manage.py migrate + - name: Compile Translations + run: docker compose -f docker-compose.local.yml run --rm django python manage.py compilemessages + - name: Run Django Tests run: docker compose -f docker-compose.local.yml run django pytest - name: Tear down the Stack run: docker compose -f docker-compose.local.yml down + + docs: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code Repository + uses: actions/checkout@v4 + + - name: Build the docs + run: docker compose -f docker-compose.docs.yml build docs + {%- else %} - name: Set up Python diff --git a/{{cookiecutter.project_slug}}/.github/workflows/merge-pr.yaml b/{{cookiecutter.project_slug}}/.github/workflows/merge-pr.yaml new file mode 100644 index 000000000..6f7a2e922 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/workflows/merge-pr.yaml @@ -0,0 +1,59 @@ +name: Merge PR + +on: + push: + branches: ["master", "main"] + +concurrency: + group: merge_pr + cancel-in-progress: false + +jobs: + bumper: + name: "Bump version number" + runs-on: ubuntu-latest + outputs: + latest_tag: {% raw %}${{ steps.latest_version.outputs.version }}{% endraw %} + bumped_tag: {% raw %}${{ steps.bumped_version.outputs.version }}{% endraw %} + steps: + - uses: actions/checkout@v4 + with: + # fetch-tags: true # NOTE: Does not work [https://github.com/actions/checkout/issues/1471] + fetch-depth: 0 + + - name: "Get current version" + id: latest_version + shell: bash + run: | + LATEST_VERSION=$(git tag --sort=-creatordate | head -n 1) + echo "Found current version: ${LATEST_VERSION}" + echo "version=${LATEST_VERSION}" >> "$GITHUB_OUTPUT" + + - name: "Bump version number" + id: bumped_version + run: | + CURRENT_VERSION="{% raw %}${{ steps.latest_version.outputs.version }}{% endraw %}" + COMMIT_MESSAGE="{% raw %}${{ github.event.head_commit.message }}{% endraw %}" + source .scripts/semver_bump.sh "$CURRENT_VERSION" "$COMMIT_MESSAGE" + + - name: "Bump project version" + run: | + BUMPED_VERSION="{% raw %}${{ steps.bumped_version.outputs.version }}{% endraw %}" + # Find and replace anything that matches `__version__ = "x.x.x"` + sed -i 's/\(^__version__ = \)"[^"]*"/__version__ = "'"${BUMPED_VERSION}"'"/' gebi/__init__.py + + - name: "Commit changes" + run: | + CURRENT_VERSION="{% raw %}${{ steps.latest_version.outputs.version }}{% endraw %}" + BUMPED_VERSION="{% raw %}${{ steps.bumped_version.outputs.version }}{% endraw %}" + + git config --global user.name "GitHub Actions" + git config --global user.email "devops@github.com" + git add gebi/__init__.py + git commit -m "Bump version from v${CURRENT_VERSION} to v${BUMPED_VERSION}" + git push origin main + + git tag ${BUMPED_VERSION} + git push origin ${BUMPED_VERSION} + + echo "Bump version from v${CURRENT_VERSION} to v${BUMPED_VERSION}" >> $GITHUB_STEP_SUMMARY