Update Generated Docs #49
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: Update Generated Docs | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "The new tolgee platform version to generate docs from." | |
jobs: | |
main: | |
name: Update docs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: "${{ secrets.TOLGEE_MACHINE_PAT }}" | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20.x" | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Set git globals | |
run: | | |
git config --local user.email "machine@tolgee.io" | |
git config --local user.name "Tolgee Machine" | |
- name: Login to docker | |
run: echo '${{ secrets.TOLGEE_MACHINE_PAT }}' | docker login ghcr.io -u USERNAME --password-stdin | |
- name: Get the version branch name part | |
id: get_branch_name | |
run: npm run get-version-branch-slug | |
env: | |
TOLGEE_NEW_VERSION: ${{ github.event.inputs.version }} | |
- name: Checkout to new branch | |
run: | | |
git checkout -b update-generated-code-${{ steps.get_branch_name.outputs.tolgee_version }} | |
- name: Run the app & wait | |
run: | | |
docker run --rm -d -p8080:8080 ghcr.io/tolgee/tolgee-ee:${{ github.event.inputs.version }} | |
curl --retry 200 --retry-delay 1 -s --retry-all-errors "http://localhost:8080/swagger-ui/index.html" > /dev/null | |
- name: Generate the code | |
run: | | |
npm run generate-api-docs | |
npm run generate-platform-config | |
env: | |
TOLGEE_NEW_VERSION: ${{ github.event.inputs.version }} | |
API_SPEC_OVERRIDE_SERVER: https://app.tolgee.io | |
- name: Check for changes | |
id: changes | |
run: | | |
git add . | |
git update-index --refresh | |
CHANGED=$(git diff-index --quiet HEAD --; echo $?) | |
echo "changed=${CHANGED}" >> $GITHUB_OUTPUT | |
- name: Commit and push | |
if: steps.changes.outputs.changed == '1' | |
run: | | |
git add . | |
git commit -m "feat: Update Generated code to platform version ${{ github.event.inputs.version }}" | |
git push origin update-generated-code-${{ steps.get_branch_name.outputs.tolgee_version }} | |
- name: Create pull request | |
if: steps.changes.outputs.changed == '1' | |
run: | | |
gh pr create -B main \ | |
-H update-generated-code-${{ steps.get_branch_name.outputs.tolgee_version }} \ | |
--title 'Update generated docs to align with ${{ github.event.inputs.version }}' \ | |
--body 'This PR was generated by GitHub Action. It updates the generated docs.' | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOLGEE_MACHINE_PAT }} |