Merge pull request #73 from firefly-iii/dependabot/composer/twig/twig… #253
This file contains hidden or 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: "Build - API documentation" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| developrun: | |
| description: 'Develop run, true or false?' | |
| required: true | |
| default: 'true' | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build_docs: | |
| name: BuildDocs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Checkout website | |
| uses: actions/checkout@v6 | |
| with: | |
| path: 'api-docs' | |
| repository: 'firefly-iii/api-docs' | |
| token: ${{ secrets.GIT_REPOS_TOKEN }} | |
| fetch-depth: 0 | |
| - id: ff3version | |
| uses: pozetroninc/github-action-get-latest-release@master | |
| with: | |
| owner: firefly-iii | |
| repo: firefly-iii | |
| excludes: prerelease, draft | |
| token: ${{ secrets.GIT_REPOS_TOKEN }} | |
| - name: Create or find branch | |
| run: | | |
| cd api-docs | |
| RES=$(git ls-remote --heads origin ${{ steps.ff3version.outputs.release }}) | |
| if [[ $RES == '' ]]; then | |
| echo "Git branch '${{ steps.ff3version.outputs.release }}' does not exist in the remote repository" | |
| git checkout -b ${{ steps.ff3version.outputs.release }} | |
| git push -u origin ${{ steps.ff3version.outputs.release }} | |
| else | |
| echo "Git branch '${{ steps.ff3version.outputs.release }}' already exists" | |
| git checkout -b ${{ steps.ff3version.outputs.release }} origin/${{ steps.ff3version.outputs.release }} | |
| fi | |
| cd .. | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.5' | |
| extensions: >- | |
| fileinfo | |
| json | |
| yaml | |
| mbstring | |
| - name: Install Composer dependencies | |
| run: composer install --prefer-dist --no-interaction --no-progress --no-scripts | |
| - name: Build documentation | |
| run: | | |
| # | |
| # Set some git things. | |
| # | |
| sudo timedatectl set-timezone Europe/Amsterdam | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git config pull.rebase false | |
| # | |
| # Go to API docs and pull the necessary branch. | |
| # | |
| cd api-docs | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git config pull.rebase false | |
| # if develop run is true, only checkout main, not the branch. | |
| if [[ "$DEV_RUN" == "true" ]]; then | |
| echo 'Do a develop run of the API docs, check out main branch.' | |
| git pull origin main | |
| git checkout main | |
| fi | |
| if [[ "$DEV_RUN" == "true" ]]; then | |
| echo "Do a normal run of the API docs, check out ${{ steps.ff3version.outputs.release }} branch" | |
| git pull origin ${{ steps.ff3version.outputs.release }} | |
| fi | |
| cd .. | |
| # | |
| # Run the actual build script. | |
| # | |
| # if developrun is true, only checkout main, not the branch. | |
| if [[ "$DEV_RUN" == "true" ]]; then | |
| echo 'Do a develop run of the API docs, build develop.' | |
| php build-api-docs.php develop | |
| fi | |
| if [[ "$DEV_RUN" == "false" ]]; then | |
| echo "Do a normal run of the API docs, build ${{ steps.ff3version.outputs.release }}" | |
| php build-api-docs.php ${{ steps.ff3version.outputs.release }} | |
| fi | |
| # | |
| # Back to the repository and push the changes. | |
| # also go back to the main branch. | |
| # | |
| cd api-docs | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git config pull.rebase false | |
| git pull origin main | |
| git add dist/firefly-iii-*-v1.yaml | |
| git add dist/index.html | |
| git commit -m "🤖 Update API documentation for Firefly III" | |
| git push | |
| env: | |
| API_DESTINATION: ./api-docs/dist | |
| API_SERVER: https://demo.firefly-iii.org | |
| API_SOURCE_ROOT: ./api-docs/src | |
| DEV_RUN: ${{ inputs.developrun || 'true' }} |