Skip to content

Commit

Permalink
Merge pull request #530 from commercetools/jenschude-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude authored Dec 15, 2023
2 parents 70be102 + e0ed32c commit f40a070
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 29 deletions.
89 changes: 66 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,31 @@ jobs:
name: Integration tests

runs-on: ubuntu-latest
permissions:
contents: write # for stefanzweifel/git-auto-commit-action to push code in repo

steps:
# Get GitHub token via the CT SDKs App
- name: Generate GitHub token (via CT SDKs App)
id: generate_github_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.SDK_APP_ID }}
private-key: ${{ secrets.SDK_APP_PEM }}

- name: Get App user
id: get_app_user
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
run: |
export GH_APP_USER=`gh api /users/ct-sdks%5Bbot%5D | jq .id`
echo "email=${GH_APP_USER}+ct-sdks[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4

with:
# Pass a personal access token (using our CT SDKs App) to be able to trigger other workflows
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
# https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/8
token: ${{ steps.generate_github_token.outputs.token }}
- uses: gradle/wrapper-validation-action@342dbebe7272035434f9baccc29a816ec6dd2c7b

- name: Setup Java
Expand All @@ -41,38 +59,53 @@ jobs:
run: ./gradlew spotlessApply

- uses: stefanzweifel/git-auto-commit-action@e8f94e4dd298db5a6a2aa2d42fe0bcef6f2c9660
id: commit_style_fix
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
with:
push_options: --dry-run
commit_message: "spotless: Fix code style"
commit_user_name: automation-commercetools
commit_user_email: automation@commercetools.com
commit_author: Auto Mation <automation@commercetools.com>
commit_author: ct-sdks[bot] <${{ steps.get_app_user.outputs.email }}>
commit_user_name: ct-sdks[bot]
commit_user_email: ${{ steps.get_app_user.outputs.email }}

- name: "Run if style changes have been detected"
if: steps.auto-commit-action.outputs.changes_detected == 'true'
if: steps.commit_style_fix.outputs.changes_detected == 'true'
run: echo "${{steps.auto-commit-action.outputs.commit_hash}}" >> .git-blame-ignore-revs

- uses: stefanzweifel/git-auto-commit-action@e8f94e4dd298db5a6a2aa2d42fe0bcef6f2c9660
id: commit_rev_ignore
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
with:
push_options: --dry-run
file_pattern: '.git-blame-ignore-revs'
commit_message: "spotless: add commit to blame ignore revs file"
commit_user_name: automation-commercetools
commit_user_email: automation@commercetools.com
commit_author: Auto Mation <automation@commercetools.com>
commit_author: ct-sdks[bot] <${{ steps.get_app_user.outputs.email }}>
commit_user_name: ct-sdks[bot]
commit_user_email: ${{ steps.get_app_user.outputs.email }}

- name: License check
run: ./gradlew checkLicense

- uses: stefanzweifel/git-auto-commit-action@e8f94e4dd298db5a6a2aa2d42fe0bcef6f2c9660
id: commit_license_change
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
with:
push_options: --dry-run
file_pattern: 'licenses/index.json licenses/**/index.json'
commit_message: "TASK: Updating license information"
commit_user_name: automation-commercetools
commit_user_email: automation@commercetools.com
commit_author: Auto Mation <automation@commercetools.com>
commit_author: ct-sdks[bot] <${{ steps.get_app_user.outputs.email }}>
commit_user_name: ct-sdks[bot]
commit_user_email: ${{ steps.get_app_user.outputs.email }}
disable_globbing: true
- name: Push if changes
if: steps.commit_style_fix.outputs.changes_detected || steps.commit_license_change.outputs.changes_detected || steps.commit_rev_ignore.outputs.changes_detected
run: git push

- name: Run integration tests for PR
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
Expand Down Expand Up @@ -113,20 +146,30 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
# Get GitHub token via the CT SDKs App
- name: Generate GitHub token (via CT SDKs App)
id: generate_github_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.SDK_APP_ID }}
private-key: ${{ secrets.SDK_APP_PEM }}

- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ steps.generate_github_token.outputs.token }}

- uses: gradle/wrapper-validation-action@342dbebe7272035434f9baccc29a816ec6dd2c7b

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@c001ccfb5aff62e28bda6a6c39b59a7e061be5b9

- name: build javadoc
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' && github.ref == 'refs/heads/main'
run: ./gradlew alljavadoc
- name: build javadoc
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' && github.ref == 'refs/heads/main'
run: ./gradlew alljavadoc
22 changes: 19 additions & 3 deletions .github/workflows/create-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,35 @@ jobs:
create_pr:
name: Create/Update PR

permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
# Get GitHub token via the CT SDKs App
- name: Generate GitHub token (via CT SDKs App)
id: generate_github_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.SDK_APP_ID }}
private-key: ${{ secrets.SDK_APP_PEM }}

- name: Get App user
id: get_app_user
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
run: |
export GH_APP_USER=`gh api /users/ct-sdks%5Bbot%5D | jq .id`
echo "email=${GH_APP_USER}+ct-sdks[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ steps.generate_github_token.outputs.token }}

- uses: gradle/wrapper-validation-action@342dbebe7272035434f9baccc29a816ec6dd2c7b

- uses: jenschude/auto-create-pr-action@8733ffe7f93fbeab30113ed3964dfb02bb6984b5
with:
request_title: "Update generated SDKs"
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ steps.generate_github_token.outputs.token }}
request_body: |
- [ ] Changeset added
Expand Down
24 changes: 21 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,34 @@ jobs:

runs-on: ubuntu-latest
steps:
# Get GitHub token via the CT SDKs App
- name: Generate GitHub token (via CT SDKs App)
id: generate_github_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.SDK_APP_ID }}
private-key: ${{ secrets.SDK_APP_PEM }}

- name: Get App user
id: get_app_user
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
run: |
export GH_APP_USER=`gh api /users/ct-sdks%5Bbot%5D | jq .id`
echo "email=${GH_APP_USER}+ct-sdks[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
with:
path: sdk
token: ${{ steps.generate_github_token.outputs.token }}

- name: Checkout
uses: actions/checkout@v4
with:
path: doc
ref: gh-pages
token: ${{ steps.generate_github_token.outputs.token }}

- name: Setup Java
uses: actions/setup-java@v3
Expand All @@ -47,6 +65,6 @@ jobs:
with:
repository: doc
commit_message: "Update javadoc"
commit_user_name: automation-commercetools
commit_user_email: automation@commercetools.com
commit_author: Auto Mation <automation@commercetools.com>
commit_author: ct-sdks[bot] <${{ steps.get_app_user.outputs.email }}>
commit_user_name: ct-sdks[bot]
commit_user_email: ${{ steps.get_app_user.outputs.email }}

0 comments on commit f40a070

Please sign in to comment.