| # Copyright 2020 Google LLC | 
 | # | 
 | # Licensed under the Apache License, Version 2.0 (the "License"); | 
 | # you may not use this file except in compliance with the License. | 
 | # You may obtain a copy of the License at | 
 | # | 
 | #      https://www.apache.org/licenses/LICENSE-2.0 | 
 | # | 
 | # Unless required by applicable law or agreed to in writing, software | 
 | # distributed under the License is distributed on an "AS IS" BASIS, | 
 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | # See the License for the specific language governing permissions and | 
 | # limitations under the License. | 
 |  | 
 | name: Publish Documentation | 
 |  | 
 | on: | 
 |   push: | 
 |     branches: | 
 |       - main | 
 |  | 
 | jobs: | 
 |   linux: | 
 |     runs-on: ubuntu-18.04 | 
 |     env: | 
 |       IREE_DOC_BUILD_DIR: build-docs | 
 |     steps: | 
 |       - name: Setup Bazel | 
 |         uses: abhinavsingh/setup-bazel@v3 | 
 |         with: | 
 |           version: 2.1.0 | 
 |       - name: Checking out repository | 
 |         uses: actions/checkout@v2 | 
 |         with: | 
 |           token: ${{ secrets.GITHUB_WRITE_ACCESS_TOKEN }} | 
 |       - name: Fetching gh-pages branch | 
 |         run: | | 
 |           git fetch origin gh-pages | 
 |       - name: Initializing submodules | 
 |         run: ./scripts/git/submodule_versions.py init | 
 |       - name: Installing Ninja build | 
 |         uses: seanmiddleditch/gha-setup-ninja@v1 | 
 |       - name: Building documentation | 
 |         run: | | 
 |           ./build_tools/cmake/build_docs.sh | 
 |           # Patch the MarkDown files with front matter for rendering | 
 |           ./scripts/prepare_doc_publication.py ${IREE_DOC_BUILD_DIR}/doc | 
 |       - name: Updating gh-pages branch | 
 |         run: | | 
 |           git checkout -f gh-pages | 
 |           cp -rf ${IREE_DOC_BUILD_DIR}/doc/* docs/ | 
 |           # The index.md will be the landing page. It should be placed in the | 
 |           # top directory. | 
 |           mv -f docs/index.md . | 
 |           git add docs/ index.md | 
 |           echo "::set-env name=has_diff::false" | 
 |           git diff --cached --exit-code || echo "::set-env name=has_diff::true" | 
 |       - name: Committing updates | 
 |         if: env.has_diff == 'true' | 
 |         run: | | 
 |           git config --local user.email "iree-github-actions-bot@google.com" | 
 |           git config --local user.name "Doc Publish Action" | 
 |           git commit -am "Automatically update GitHub Pages" | 
 |       - name: Pushing changes | 
 |         if: env.has_diff == 'true' | 
 |         uses: ad-m/github-push-action@v0.5.0 | 
 |         with: | 
 |           github_token: ${{ secrets.GITHUB_WRITE_ACCESS_TOKEN }} | 
 |           branch: gh-pages |