-
Notifications
You must be signed in to change notification settings - Fork 0
ci: split the workflows #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ba4a2ec
9d74fec
9637942
43d91a9
64e35d3
1ec5b50
e4cd1a4
578657b
016003c
7d8d989
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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@v5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 . . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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 | |
| - 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 }} |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
||||||
| run: mvn clean verify -ntp | |
| run: mvn -B clean verify -ntp |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||||||||
| name: Generate Template | ||||||||||||
| on: | ||||||||||||
| workflow_dispatch: | ||||||||||||
|
||||||||||||
| workflow_dispatch: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write |
Copilot
AI
Oct 18, 2025
There was a problem hiding this comment.
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.
| # create unique branch name starting with "generated-template" | |
| # create unique branch name starting with "template-" |
Copilot
AI
Oct 18, 2025
There was a problem hiding this comment.
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.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,14 +1,14 @@ | ||||||||
| #!/bin/bash | ||||||||
|
||||||||
| #!/bin/bash | |
| #!/bin/bash | |
| set -euo pipefail |
There was a problem hiding this comment.
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.