Generate PRs to client libraries repositories #22
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 | |
jobs: | |
build_client_libraries: | |
name: "${{ matrix.generator }}: build library" | |
runs-on: ubuntu-latest | |
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 \ | |
git | |
- name: Refresh client library | |
run: | | |
./generator/script/generate.sh | |
- name: Extract information from build | |
id: extract_data | |
run: | | |
echo apiDefTag=$(git describe --tags --always) | sed 's/: /=/' >> $GITHUB_OUTPUT | |
- name: Store generated artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }} | |
path: | | |
generated/artifacts | |
!generated/artifacts/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" | |
runs-on: ubuntu-latest | |
needs: | |
- build_client_libraries | |
strategy: | |
matrix: | |
include: | |
- generator: typescript-axios | |
git_repo_id: onfido-node | |
- generator: typescript-fetch | |
git_repo_id: onfido-node-fetch | |
# environment: | |
# name: ${{ matrix.git_repo }}-generation | |
# if: github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# token: ${{ secrets.GITHUB_ACTION_ACCESS_TOKEN }} | |
repository: onfido/${{ matrix.git_repo_id }} | |
sparse-checkout: | | |
.github | |
- uses: actions/download-artifact@v4 | |
with: | |
name: artifacts-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }} | |
path: generated/artifacts | |
- name: Commit and push client library update | |
run: | | |
git --version | |
sudo rsync --remove-source-files generated/artifacts/${{ matrix.generator }}/ . | |
rm -rf generated | |
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 ${{ needs.build_client_libraries.outputs.api_def_tag }}" | |
git log | |
# git push | |
fi |