Skip to content

ci: split the workflows - #60

Merged
paul58914080 merged 10 commits into
mainfrom
ci/split-workflow
Oct 18, 2025
Merged

ci: split the workflows#60
paul58914080 merged 10 commits into
mainfrom
ci/split-workflow

Conversation

@paul58914080

@paul58914080 paul58914080 commented Oct 18, 2025

Copy link
Copy Markdown
Member

Description

According to github's security we cannot use PAT_TOKEN for workflows. We need to generate the template code from the example and push the changes hence had to split the workflow based on manual trigger

Checklist:

  • My code follows the contribution guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • My commits follow conventional commit message guidelines

Copilot AI review requested due to automatic review settings October 18, 2025 06:41
@paul58914080
paul58914080 requested a review from a team as a code owner October 18, 2025 06:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Splits CI into separate workflows to avoid using PAT_TOKEN and enable manually triggered template generation, while adjusting CI to verify builds and adding a template-based CI path.

  • Introduces a manual "Generate Template" workflow to create a branch, generate from example, push changes, and open a PR using GITHUB_TOKEN.
  • Removes in-CI template generation from the main CI workflow and switches Maven phase to verify.
  • Adds a separate workflow to generate a project from the template and run CI against the generated app.

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
generate-cookiecutter-template-from-example-project.sh Renames working directory from example-tryout to example-template to align with new workflows.
.github/workflows/generate-template.yaml New manual workflow to generate template, push a branch, and auto-create a PR.
.github/workflows/ci.yaml Simplifies CI to run mvn verify and removes template generation job.
.github/workflows/ci-from-template.yaml New workflow to generate from cookiecutter and run CI on the generated project.
.github/dependabot.yml Updates reviewers to a team.

Comment on lines +4 to +7
branches:
- main
jobs:
generate-template:

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workflow_dispatch does not support a branches filter. Remove the branches block; if you need to restrict execution to main, gate the job with a condition like if: github.ref == 'refs/heads/main'.

Suggested change
branches:
- main
jobs:
generate-template:
jobs:
generate-template:
if: github.ref == 'refs/heads/main'

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci-from-template.yaml Outdated
Comment thread .github/dependabot.yml Outdated
- name: Create new branch
id: create_branch
run: |
# create unique branch name starting with "generated-template"

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment and implementation are inconsistent: the comment says the prefix is generated-template, but the code uses template-. Update the comment or the branch prefix for consistency.

Suggested change
# create unique branch name starting with "generated-template"
# create unique branch name starting with "template-"

Copilot uses AI. Check for mistakes.
paul58914080 and others added 3 commits October 18, 2025 12:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@paul58914080
paul58914080 requested a review from Copilot October 18, 2025 06:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.

Comment on lines +43 to +54
- 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

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The create-pull-request action will not open a PR if there are no uncommitted changes at this step (you already committed and pushed earlier), so this step can silently do nothing. Replace this with a PR-creation step that opens a PR for an already-pushed branch (for example, actions/github-script calling pulls.create, or gh pr create), or let peter-evans/create-pull-request handle both committing and PR creation by removing the prior manual git commit/push.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,54 @@
name: Generate Template
on:
workflow_dispatch:

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow pushes a branch and creates a PR using GITHUB_TOKEN but does not declare explicit permissions. Add a top-level permissions block (contents: write and pull-requests: write) to ensure the token has sufficient rights across all repo/org settings.

Suggested change
workflow_dispatch:
workflow_dispatch:
permissions:
contents: write
pull-requests: write

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +46
- 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: Download generated cart-service artifact
uses: actions/download-artifact@v4
with:
name: cart-service

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] "cart-service" is hard-coded; if the app_name in test-config.yml changes, this step will break. Consider centralizing the generated directory name in a single workflow env var (kept in sync with test-config.yml) and reference it here to avoid drift.

Suggested change
- 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: Download generated cart-service artifact
uses: actions/download-artifact@v4
with:
name: cart-service
- name: Extract generated app name from test-config.yml
id: extract_app_name
run: |
echo "GENERATED_APP_NAME=$(python -c "import yaml; print(yaml.safe_load(open('test-config.yml'))['app_name'])")" >> $GITHUB_ENV
env:
PYTHONPATH: ""
- name: Upload generated app as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.GENERATED_APP_NAME }}
path: ./${{ env.GENERATED_APP_NAME }}
cart-service-ci:
needs: generate-from-template
defaults:
run:
working-directory: ./${{ env.GENERATED_APP_NAME }}
runs-on: ubuntu-latest
steps:
- name: Download generated cart-service artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.GENERATED_APP_NAME }}

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +41
cart-service-ci:
needs: generate-from-template
defaults:
run:
working-directory: ./cart-service
runs-on: ubuntu-latest

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The job name and working-directory are hard-coded to cart-service; if the generated app_name changes, the job will fail or become misleading. Use a workflow env var (e.g., GENERATED_DIR) for both the job's working-directory and artifact name/path to keep them aligned with test-config.yml.

Copilot uses AI. Check for mistakes.
@@ -1,14 +1,14 @@
#!/bin/bash

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Add strict mode to improve robustness and fail fast on errors. For example, place set -euo pipefail immediately after the shebang.

Suggested change
#!/bin/bash
#!/bin/bash
set -euo pipefail

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yaml
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

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding -B to Maven commands in CI (non-interactive/batch mode): mvn -B clean verify -ntp. This is a common CI convention that also reduces noise from interactive prompts.

Suggested change
run: mvn clean verify -ntp
run: mvn -B clean verify -ntp

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci-from-template.yaml Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@paul58914080 paul58914080 self-assigned this Oct 18, 2025
@paul58914080
paul58914080 merged commit 9a18405 into main Oct 18, 2025
1 check passed
@paul58914080
paul58914080 deleted the ci/split-workflow branch October 18, 2025 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants