From ba4a2ec56676a5a25950afb8ab11c9088e04add1 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 11:55:21 +0530 Subject: [PATCH 01/10] ci: update reviewers for Dependabot configuration --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0cb2926..6126407 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,4 +8,4 @@ updates: time: "23:30" open-pull-requests-limit: 10 reviewers: - - paul58914080 \ No newline at end of file + - '@devs-from-matrix/app-generator-team' \ No newline at end of file From 9d74fec3f93b486e84f065e92e11698d1c66db7e Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 11:56:07 +0530 Subject: [PATCH 02/10] ci: rename example-tryout to example-template in generation script --- ...e-cookiecutter-template-from-example-project.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/generate-cookiecutter-template-from-example-project.sh b/generate-cookiecutter-template-from-example-project.sh index 51538f3..719b1ea 100755 --- a/generate-cookiecutter-template-from-example-project.sh +++ b/generate-cookiecutter-template-from-example-project.sh @@ -1,14 +1,14 @@ #!/bin/bash # This script is used to rename files and directories in the example project to that of the cookiecutter template. -# Remove previous example-tryout directory if it exists -if [ -d "example-tryout" ]; then - rm -rf "example-tryout" +# Remove previous example-template directory if it exists +if [ -d "example-template" ]; then + rm -rf "example-template" fi -# Create a new example-tryout directory and copy the example project into it -mkdir "example-tryout" -rsync -a ./example/ ./example-tryout/ -cd ./example-tryout +# Create a new example-template directory and copy the example project into it +mkdir "example-template" +rsync -a ./example/ ./example-template/ +cd ./example-template # sets the locale for all commands run in the current shell session to the "C" locale, which is the default POSIX locale. This makes programs like sed and find treat files as raw bytes, ignoring any character encoding issues. It helps avoid errors like illegal byte sequence when processing files with mixed or unknown encodings. export LC_ALL=C From 9637942b53d7586579e69b6fd0e3eb9d10c05dde Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 11:57:22 +0530 Subject: [PATCH 03/10] ci: remove generate-template job --- .github/workflows/ci.yaml | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 98b23ae..2f3a1a5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,28 +29,4 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - name: Build with Maven - run: mvn clean install -ntp - - name: Clean up - run: mvn clean - generate-template: - needs: example-ci - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - token: ${{ secrets.PAT_TOKEN }} - - name: Make script executable - run: chmod +x ./generate-cookiecutter-template-from-example-project.sh - - name: Generate cookiecutter template - run: ./generate-cookiecutter-template-from-example-project.sh - - name: Copy generated template to {{cookiecutter.app_name}} - run: | - rsync -a --delete --exclude='.git' ./example-tryout/ ./{{cookiecutter.app_name}}/ - - name: Commit & push generated changes - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git add . - git diff --cached --quiet || git commit -m "ci: update generated cookiecutter template from example" - git push origin ${{ github.head_ref }} + run: mvn clean verify -ntp From 43d91a90e8e9ce62d2cf520e2fbbbd5e65b3d4d4 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 11:58:46 +0530 Subject: [PATCH 04/10] ci: add workflow for generating cookiecutter template from example project --- .github/workflows/generate-template.yaml | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/generate-template.yaml diff --git a/.github/workflows/generate-template.yaml b/.github/workflows/generate-template.yaml new file mode 100644 index 0000000..ee1bf6b --- /dev/null +++ b/.github/workflows/generate-template.yaml @@ -0,0 +1,56 @@ +name: Generate Template +on: + workflow_dispatch: + branches: + - main +jobs: + generate-template: + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + - name: Create new branch + id: create_branch + run: | + # create unique branch name starting with "generated-template" + BRANCH="template-$(date +%Y%m%d%H%M%S)" + echo "branch=${BRANCH}" >> $GITHUB_OUTPUT + git config user.email "github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + git checkout -b "${BRANCH}" + git push --set-upstream origin "${BRANCH}" + - name: Ensure working on created branch + run: | + git fetch origin + git checkout "${{ steps.create_branch.outputs.branch }}" + - name: Make script executable + run: chmod +x ./generate-cookiecutter-template-from-example-project.sh + - name: Generate cookiecutter template + run: ./generate-cookiecutter-template-from-example-project.sh + - name: Copy generated template to {{cookiecutter.app_name}} + run: | + rsync -a --delete --exclude='.git' ./example-template/ ./{{cookiecutter.app_name}}/ + - name: Commit & push generated changes + env: + BRANCH: ${{ steps.create_branch.outputs.branch }} + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add . + git diff --cached --quiet || git commit -m "ci: update generated cookiecutter template from example" + git push origin "${BRANCH}" + - name: Create Pull Request + id: create_pr + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + base: main + branch: ${{ steps.create_branch.outputs.branch }} + title: "ci: update generated cookiecutter template from example" + body: | + This PR was created automatically by the Generate Template workflow. + Contains updates generated from the example project. + labels: automated-pr From 64e35d35c39c426eb9cfdc15d2c969d7cfd1335f Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 12:03:07 +0530 Subject: [PATCH 05/10] chore(gitignore): add example-template --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c698b83..be2f91d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ *.iml ## Generated projects -# The generated project from scaffold-code-from-example.sh -example-tryout +# The generated project from generate-cookiecutter-template-from-example-project.sh +example-template # The generated project from cookiecutter cart-service From 1ec5b5056cdbad1d0ff838fee3dc4ddc2dbcca0d Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 12:03:33 +0530 Subject: [PATCH 06/10] ci: add CI workflow for generating projects from cookiecutter template --- .github/workflows/ci-from-template.yaml | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/ci-from-template.yaml diff --git a/.github/workflows/ci-from-template.yaml b/.github/workflows/ci-from-template.yaml new file mode 100644 index 0000000..2a35082 --- /dev/null +++ b/.github/workflows/ci-from-template.yaml @@ -0,0 +1,52 @@ +name: Continuous Integration From Template +on: + pull_request: + branches: + - main + paths: + - '{{cookiecutter.app_name}}/**' + workflow_dispatch: +jobs: + generate-from-template: + runs-on: ubuntu-latest + steps: + - name: Checkout PR branch + uses: actions/checkout@v4 + with: + # checkout the pull request head ref when available, otherwise fallback to the workflow ref + ref: ${{ github.head_ref || github.ref }} + token: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install cookiecutter + run: | + pip install --upgrade pip cookiecutter + - name: Generate from default context (cookiecutter.json) + run: | + # Generate using the config file test-config.yml from the repo root. + # Use the repo root as the template directory (.) and overwrite any existing generated output. + cookiecutter --no-input --config-file test-config.yml --overwrite-if-exists --output-dir . . + cart-service-ci: + defaults: + run: + working-directory: ./cart-service + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Build with Maven + run: mvn clean verify -ntp From e4cd1a43502487a1de4049395b48e06cc6f4efb3 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 12:14:10 +0530 Subject: [PATCH 07/10] ci(dependabot): update reviewer Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6126407..037859f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,4 +8,4 @@ updates: time: "23:30" open-pull-requests-limit: 10 reviewers: - - '@devs-from-matrix/app-generator-team' \ No newline at end of file + - devs-from-matrix/app-generator-team \ No newline at end of file From 578657b14687e9e37b1cdb81ff64536631564866 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 12:17:03 +0530 Subject: [PATCH 08/10] ci: update generate-template workflow to remove branch restriction --- .github/workflows/generate-template.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/generate-template.yaml b/.github/workflows/generate-template.yaml index ee1bf6b..7cdb878 100644 --- a/.github/workflows/generate-template.yaml +++ b/.github/workflows/generate-template.yaml @@ -1,8 +1,6 @@ name: Generate Template on: workflow_dispatch: - branches: - - main jobs: generate-template: runs-on: ubuntu-latest From 016003cabeaeea2ad66a3d980ada27687037e951 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 12:20:27 +0530 Subject: [PATCH 09/10] ci: use cart-service as an artifact Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/ci-from-template.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-from-template.yaml b/.github/workflows/ci-from-template.yaml index 2a35082..2ff4761 100644 --- a/.github/workflows/ci-from-template.yaml +++ b/.github/workflows/ci-from-template.yaml @@ -28,14 +28,23 @@ jobs: # Generate using the config file test-config.yml from the repo root. # Use the repo root as the template directory (.) and overwrite any existing generated output. cookiecutter --no-input --config-file test-config.yml --overwrite-if-exists --output-dir . . + - name: Upload generated cart-service as artifact + uses: actions/upload-artifact@v4 + with: + name: cart-service + path: ./cart-service cart-service-ci: + needs: generate-from-template defaults: run: working-directory: ./cart-service runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Download generated cart-service artifact + uses: actions/download-artifact@v4 + with: + name: cart-service + path: . - name: Set up JDK 21 uses: actions/setup-java@v4 with: From 7d8d98969e26a9cff5ac944a0f15daeca3993cf2 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Sat, 18 Oct 2025 12:25:36 +0530 Subject: [PATCH 10/10] ci: use actions/setup-python@v5 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/ci-from-template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-from-template.yaml b/.github/workflows/ci-from-template.yaml index 2ff4761..93c173a 100644 --- a/.github/workflows/ci-from-template.yaml +++ b/.github/workflows/ci-from-template.yaml @@ -17,7 +17,7 @@ jobs: ref: ${{ github.head_ref || github.ref }} token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install cookiecutter