Generate PRs to client libraries repositories #83
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: client-libraries-pull-request | |
run-name: Generate PRs to client libraries repositories | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- 'generated/artifacts/**' | |
pull_request: | |
branches: | |
- master | |
workflow_dispatch: | |
inputs: | |
type-of-change: | |
description: 'Type of change?' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- Mayor | |
- Minor | |
- Patch | |
update-onfido-node: | |
description: 'Update onfido-node?' | |
required: true | |
default: false | |
type: boolean | |
env: | |
GITHUB_SHA: env.GITHUB_SHA | |
jobs: | |
build_client_libraries: | |
name: "build client libraries" | |
runs-on: ubuntu-latest | |
outputs: | |
typescript_axios_version: ${{ steps.generator.outputs.typescript_axios_version }} | |
container: | |
image: openapitools/openapi-generator-cli:v7.3.0 | |
env: | |
OPENAPI_GENERATOR_COMMAND: docker-entrypoint.sh | |
BUMP_CLIENT_LIBRARY_VERSION: ${{ inputs.type-of-change || 'Minor' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install pre-requisites | |
run: | | |
apt-get update | |
apt-get install -yqq \ | |
gettext-base \ | |
git \ | |
jq | |
- name: Regenerate client libraries | |
id: generator | |
run: | | |
./shell/generate.sh | |
- name: Extract information from build | |
id: data_gathering | |
run: | | |
pwd | |
ls -lhA | |
echo apiDefTag="$(git describe --tags --always)" | sed 's/: /=/' >> $GITHUB_OUTPUT | |
- name: Store generated artifacts and finalization scripts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }} | |
path: | | |
generated/artifacts | |
generators/*/exclusions.txt | |
generators/*/finalize.sh | |
!generated/artifacts/openapi* | |
!generators/openapi* | |
# - name: Store generated configuration | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: configuration-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }}-${{ matrix.generator }} | |
# path: generated/configuration/${{ matrix.generator }}.yaml | |
# reusable: | |
create_pr: | |
name: "${{ matrix.generator }}: commit and create pull request to ${{ matrix.git_repo_id }} repository (update: ${{matrix.update}})" | |
runs-on: ubuntu-latest | |
needs: | |
- build_client_libraries | |
strategy: | |
matrix: | |
include: | |
- generator: typescript-axios | |
git_repo_id: onfido-node | |
version: ${{ needs.build_client_libraries.outputs.typescript_axios_version }} | |
update: ${{ inputs.update-onfido-node || true }} | |
# environment: | |
# name: ${{ matrix.git_repo }}-generation | |
# if: github.event_name == 'push' | |
# if: github.event_name == 'workflow_dispatch' && | |
steps: | |
- uses: actions/checkout@v4 | |
if: ${{ matrix.update }} | |
with: | |
# token: ${{ secrets.GITHUB_ACTION_ACCESS_TOKEN }} | |
repository: onfido/${{ matrix.git_repo_id }} | |
- uses: actions/download-artifact@v4 | |
if: ${{ matrix.update }} | |
with: | |
name: artifacts-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }} | |
- name: Integrate generated code (${{ matrix.version }}) | |
if: ${{ matrix.update }} | |
id: generator | |
run: | | |
rsync -r --delete-after --exclude='/.git*' \ | |
--exclude-from=generators/${{ matrix.generator }}/exclusions.txt \ | |
generated/artifacts/${{ matrix.generator }}/ . | |
if [ -f generators/${{ matrix.generator }}/finalize.sh ]; | |
then | |
generators/${{ matrix.generator }}/finalize.sh | |
fi | |
echo any_change=$(git status --porcelain=v1 | wc -l | sed -e 's/^[[:space:]]*//') >> $GITHUB_OUTPUT | |
- name: Create Pull Request with changes after library update | |
uses: peter-evans/create-pull-request@v6 | |
if: ${{ matrix.update && steps.generator.outputs.any_change }} | |
with: | |
# token: ${{ secrets.GITHUB_ACTION_ACCESS_TOKEN }} | |
commit-message: Client library upgrade after OpenAPI change (${{ matrix.version }}) | |
title: Client library upgrade after OpenAPI change (${{ matrix.version }}) | |
body: | | |
- Dependency updates | |
Auto-generated after change: ${{ env.GITHUB_SHA }} | |
branch: refresh-library |