This repository has been archived by the owner on Aug 25, 2023. It is now read-only.
automatic SDK update #8259
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: automatic SDK update | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '*/30 * * * 1-5' | |
jobs: | |
generate-sdk: | |
name: Generate SDK | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout the code of the application | |
uses: actions/checkout@v1 | |
with: | |
persist-credentials: false | |
- name: install node ${{ matrix.node-version }} on the container | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 18.4.0 | |
- name: install npm dependencies | |
run: npm ci | |
- name: increment version | |
run: | | |
git config user.email "apena@gladia.io" | |
git config user.name "GladIA CI" | |
npm version patch -m "[release] %s" | |
- name: generate metadata | |
run: npm run generate-metadata | |
- name: should we update the sdk? | |
# this commit will return 1 if there is some modification on the listed files, 0 otherwise | |
# if the result is zero we stop the job here, because we consider there is no modifications | |
run: | | |
git diff --shortstat -- src/meta/endpoint-defs.ts | |
echo "SHOULD_UPDATE=$(git diff --shortstat -- src/meta/endpoint-defs.ts | wc -l)" >> $GITHUB_ENV | |
- name: generate sdk | |
if: ${{ env.SHOULD_UPDATE != 0 }} | |
run: npm run generate-sdk | |
- name: lint | |
if: ${{ env.SHOULD_UPDATE != 0 }} | |
run: npm run lint | |
- name: tests | |
if: ${{ env.SHOULD_UPDATE != 0 }} | |
run: npm run test | |
- name: build the application | |
if: ${{ env.SHOULD_UPDATE != 0 }} | |
run: npm run build | |
- name: create release | |
if: ${{ env.SHOULD_UPDATE != 0 }} | |
run: | | |
git add . | |
COMMIT_MSG=`git show --format=format:%B -s` | |
git commit --amend -m "$COMMIT_MSG [skip ci]" | |
- name: remove .gitignores | |
if: ${{ env.SHOULD_UPDATE != 0 }} | |
# This step is mandatory, otherwise the lib/ directory will not be package | |
run: | | |
rm .gitignore | |
mv .gitignore.npm .gitignore | |
- name: Publish release to NPM | |
if: ${{ env.SHOULD_UPDATE != 0 }} | |
uses: JS-DevTools/npm-publish@v1 | |
with: | |
access: public | |
token: ${{ secrets.NPM_TOKEN }} | |
- name: Push release | |
if: ${{ env.SHOULD_UPDATE != 0 }} | |
uses: CasperWA/push-protected@v2 | |
with: | |
token: ${{ secrets.PUSH_TO_MAIN }} | |
branch: main | |
tags: true | |
update_app: | |
needs: [generate-sdk] | |
name: trigger new app generation | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
curl -X POST \ | |
-H "Authorization: Bearer $GRANULAR_ACCESS_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/gladiaio/app/actions/workflows/update_deps.yml/dispatches \ | |
-d '{"ref": "main"}' | |
env: | |
GRANULAR_ACCESS_TOKEN: ${{secrets.GRANULAR_ACCESS_TOKEN}} |