Update Final Branch Docs #45
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: Update Final Branch Docs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: '0 4 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main branch | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: main | |
| - name: Checkout final branch | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: final | |
| path: final-branch | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '.ruby-version' | |
| bundler-cache: false | |
| - name: Run fetch-external-content | |
| run: ruby scripts/fetch-external-content.rb | |
| - name: Run prepare-docs | |
| run: ruby scripts/prepare-docs.rb --no-placeholders | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "openhab-bot" | |
| git config --global user.email "bot@openhab.org" | |
| - name: Update files in final branch | |
| working-directory: final-branch | |
| run: | | |
| # Remove existing directories in final branch checkout | |
| rm -rf docs images addons scripts .vuepress | |
| # Copy updated directories from the main branch workspace | |
| cp -r ../docs ./ | |
| cp -r ../images ./ | |
| cp -r ../addons ./ | |
| cp -r ../scripts ./ | |
| cp -r ../.vuepress ./ | |
| # Stage the changes | |
| git add docs images addons scripts .vuepress | |
| - name: Commit and push if changed | |
| id: commit_push | |
| working-directory: final-branch | |
| run: | | |
| if git diff --cached --quiet; then | |
| echo "committed=false" >> $GITHUB_OUTPUT | |
| echo "No changes to commit" | |
| else | |
| git commit -m "[ci] Automated docs update from main branch & fetch-external-content" | |
| git push origin final | |
| echo "committed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Trigger Netlify build for next.openhab.org | |
| if: steps.commit_push.outputs.committed == 'true' | |
| env: | |
| NETLIFY_HOOK: ${{ secrets.NETLIFY_HOOK }} | |
| run: | | |
| curl -X POST -d {} "https://api.netlify.com/build_hooks/$NETLIFY_HOOK" |