diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 066806e..f54fbb4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,10 +2,10 @@ version: 2 updates: - package-ecosystem: maven directories: - - "/{{cookiecutter.app_name}}/" + - "/examples/" schedule: interval: daily time: "23:30" -# open-pull-requests-limit: 10 + open-pull-requests-limit: 10 reviewers: - paul58914080 \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..0af10cf --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,52 @@ +name: Continuous Integration +on: + pull_request: + branches: + - main + paths: + - 'example/**' + - '.github/workflows/ci.yaml' + workflow_dispatch: +jobs: + example-ci: + defaults: + run: + working-directory: ./example + 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 install -ntp + generate-template: + needs: example-ci + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - 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 pull --rebase origin ${{ github.head_ref }} + git add . + git diff --cached --quiet || git commit -m "ci: update generated cookiecutter template from example" + git push origin HEAD:${{ github.head_ref }} diff --git a/.github/workflows/generate-cookiecutter-template-from-example-project.yaml b/.github/workflows/generate-cookiecutter-template-from-example-project.yaml index da2f166..c91f743 100644 --- a/.github/workflows/generate-cookiecutter-template-from-example-project.yaml +++ b/.github/workflows/generate-cookiecutter-template-from-example-project.yaml @@ -1,26 +1,26 @@ -name: Generate cookiecutter template from example project -on: - pull_request: - branches: - - main - paths: - - 'example/**' - workflow_dispatch: -jobs: - generate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - 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: Is there is difference in the generated template? - run: | - set -e - DIFF_OUTPUT=$(diff -qr example-tryout {{cookiecutter.app_name}} --exclude='.DS_Store' || true) - if [ -n "$DIFF_OUTPUT" ]; then - echo "$DIFF_OUTPUT" - echo "$DIFF_OUTPUT" > diff-output.txt - exit 1 - fi +#name: Generate cookiecutter template from example project +#on: +# pull_request: +# branches: +# - main +# paths: +# - 'example/**' +# workflow_dispatch: +#jobs: +# generate: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - 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: Is there is difference in the generated template? +# run: | +# set -e +# DIFF_OUTPUT=$(diff -qr example-tryout {{cookiecutter.app_name}} --exclude='.DS_Store' || true) +# if [ -n "$DIFF_OUTPUT" ]; then +# echo "$DIFF_OUTPUT" +# echo "$DIFF_OUTPUT" > diff-output.txt +# exit 1 +# fi diff --git a/.github/workflows/scaffold-from-template-target-project.yml b/.github/workflows/scaffold-from-template-target-project.yml index 866b4c3..8e3b84b 100644 --- a/.github/workflows/scaffold-from-template-target-project.yml +++ b/.github/workflows/scaffold-from-template-target-project.yml @@ -1,41 +1,41 @@ -name: Scaffold code from template -on: - pull_request: - branches: - - main - paths: - - '{{cookiecutter.app_name}}/**' - workflow_dispatch: -jobs: - scaffold: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: Cache pip - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - - name: Install cookiecutter - run: pip install cookiecutter - - name: Test cookiecutter - run: cookiecutter --config-file=test-config.yml --no-input . - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '21' - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - - name: Build with Maven - run: | - cd cart-service - mvn git-code-format:format-code - mvn clean install -ntp \ No newline at end of file +#name: Scaffold code from template +#on: +# pull_request: +# branches: +# - main +# paths: +# - '{{cookiecutter.app_name}}/**' +# workflow_dispatch: +#jobs: +# scaffold: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - name: Set up Python +# uses: actions/setup-python@v5 +# with: +# python-version: '3.9' +# - name: Cache pip +# uses: actions/cache@v4 +# with: +# path: ~/.cache/pip +# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} +# - name: Install cookiecutter +# run: pip install cookiecutter +# - name: Test cookiecutter +# run: cookiecutter --config-file=test-config.yml --no-input . +# - name: Set up JDK 21 +# uses: actions/setup-java@v4 +# with: +# distribution: 'temurin' +# java-version: '21' +# - name: Cache Maven packages +# uses: actions/cache@v4 +# with: +# path: ~/.m2 +# key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} +# - name: Build with Maven +# run: | +# cd cart-service +# mvn git-code-format:format-code +# mvn clean install -ntp \ No newline at end of file diff --git a/generate-cookiecutter-template-from-example-project.sh b/generate-cookiecutter-template-from-example-project.sh old mode 100644 new mode 100755