Skip to content

Generate PRs to client libraries repositories #10

Generate PRs to client libraries repositories

Generate PRs to client libraries repositories #10

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
jobs:
build_client_libraries:
name: "${{ matrix.generator }}: build library"
runs-on: ubuntu-latest
strategy:
matrix:
generator:
- typescript-axios
- typescript-fetch
outputs:
git_repo_id: ${{ steps.extract_data.outputs.gitRepoId }}
container:
image: openapitools/openapi-generator-cli:v7.3.0
env:
OPENAPI_GENERATOR_COMMAND: docker-entrypoint.sh
steps:
- uses: actions/checkout@v4
- name: Install pre-requisites
run: |
apt-get update
apt-get install -yqq \
gettext-base
- name: Refresh client library
run: |
./generator/script/generate.sh \
generator/configuration/${{ matrix.generator }}.yaml
- name: Extract target repository name
id: extract_data
run: |
grep gitRepoId generated/configuration/typescript-axios.yaml | sed 's/: /=/' >> $GITHUB_OUTPUT
- name: Store generated artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }}-${{ matrix.generator }}
path: generated/artifacts/${{ matrix.generator }}
create_pr:
name: "${{ matrix.generator }}: commit and create pull request to ${{ needs.build_client_libraries.outputs.git_repo_id }} repository"
runs-on: ubuntu-latest
needs: build_client_libraries
strategy:
matrix:
generator:
- typescript-axios
- typescript-fetch
# if: github.event_name == 'push'
steps:
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"
- name: Dump needs context
env:
NEEDS_CONTEXT: ${{ toJson(needs) }}
run: echo "$NEEDS_CONTEXT"
- uses: actions/checkout@v4
with:
# token: ${{ secrets.GITHUB_ACTION_ACCESS_TOKEN }}
repository: onfido/${{ needs.build_client_libraries.outputs.git_repo_id }} #'onfido/onfido-node'
- uses: actions/download-artifact@v4
with:
name: artifacts-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }}-${{ matrix.generator }}
- name: Commit and push client library update
run: |
git --version
if [ -z "$(git status --porcelain=v1)" ];
then
echo "no change detected"
else
echo "changes detected"
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git status
git commit -am "Client library upgrade after OpenAPI change"
# git push
fi