Skip to content

Generate PRs to client libraries repositories #12

Generate PRs to client libraries repositories

Generate PRs to client libraries repositories #12

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 }}
api_def_tag: ${{ steps.extract_data.outputs.apiDefTag }}
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 information from build
id: extract_data
run: |
grep gitRepoId generated/configuration/${{ matrix.generator }}.yaml | sed 's/: /=/' >> $GITHUB_OUTPUT
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 }}-${{ 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: |

Check failure on line 76 in .github/workflows/client-libraries-pull-request.yaml

View workflow run for this annotation

GitHub Actions / client-libraries-pull-request

Invalid workflow file

The workflow is not valid. .github/workflows/client-libraries-pull-request.yaml (Line: 76, Col: 14): Unrecognized named-value: 'api_def_tag'. Located at position 1 within expression: api_def_tag
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 ${{api_def_tag}}"
git log
# git push
fi