Skip to content

chore: synced file(s) with sumup/apis #25

chore: synced file(s) with sumup/apis

chore: synced file(s) with sumup/apis #25

Workflow file for this run

name: Generate
on:
workflow_dispatch: {}
pull_request:
paths:
- openapi.json
branches:
- main
concurrency:
group: generate-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.ref || github.ref }}
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v5.2.0
with:
go-version-file: codegen/go.mod
- name: Generate SDK
run: go -C codegen run . generate
- name: Set up Java
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v4.4.0
with:
distribution: temurin
java-version: '21'
cache: gradle
- name: Format SDK code
run: ./gradlew spotlessApply
- name: Build
run: ./gradlew build
- name: Create GitHub App token
id: app-token
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
with:
app-id: ${{ secrets.SUMUP_BOT_APP_ID }}
private-key: ${{ secrets.SUMUP_BOT_PRIVATE_KEY }}
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Configure git
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
- name: Commit changes
id: commit
run: |
git add .
if git diff --cached --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
git commit -m "chore: generate code"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Push changes
if: steps.commit.outputs.changed == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
TARGET_REPO: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
TARGET_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }}
run: |
git push "https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git" "HEAD:${TARGET_REF}"