|
| 1 | +name: PR build for ver 3.8 |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ "3.9" ] |
| 6 | + types: |
| 7 | + - opened # open PR |
| 8 | + - synchronize # update the branch which pulled from |
| 9 | + - reopened # re-open PR |
| 10 | + |
| 11 | +jobs: |
| 12 | + pr_build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Prepare environment variables |
| 17 | + run: | |
| 18 | + ref=${GITHUB_REF#refs/pull/} |
| 19 | + pr_num=${ref%/merge} |
| 20 | + |
| 21 | + echo "::set-env name=PR_BUILD_ID::${GITHUB_BASE_REF}/${pr_num}" |
| 22 | + echo "::set-env name=DOCS_BASE_DIR::build/html" |
| 23 | + echo "::set-env name=DOCS_OUTPUT_DIR::build/html/${GITHUB_BASE_REF}/${pr_num}" |
| 24 | + |
| 25 | + - name: Checkout cpython repository |
| 26 | + uses: actions/checkout@v2 |
| 27 | + with: |
| 28 | + repository: python-doc-ja/cpython-doc-catalog |
| 29 | + ref: catalog-3.8 |
| 30 | + path: cpython |
| 31 | + |
| 32 | + |
| 33 | + - name: Checkout PR branch |
| 34 | + uses: actions/checkout@v2 |
| 35 | + with: |
| 36 | + ref: ${{ github.ref }} |
| 37 | + path: cpython/Doc/locales/ja/LC_MESSAGES |
| 38 | + |
| 39 | + - name: Checkout GitHub Pages |
| 40 | + uses: actions/checkout@v2 |
| 41 | + with: |
| 42 | + ref: gh-pages |
| 43 | + path: build/html |
| 44 | + |
| 45 | + - name: Install dependencies |
| 46 | + run: | |
| 47 | + sudo apt-get update |
| 48 | + sudo apt-get install -y --no-install-recommends python3-venv |
| 49 | +
|
| 50 | + - name: Build docs |
| 51 | + run: | |
| 52 | + cd cpython/Doc |
| 53 | + make venv |
| 54 | + rm -rf ${DOCS_OUTPUT_DIR} |
| 55 | + make build ALLSPHINXOPTS="-b html -D language=ja -D gettext_compact=0 -E -d build/doctrees . ${GITHUB_WORKSPACE}/${DOCS_OUTPUT_DIR}" |
| 56 | + ls -l ${GITHUB_WORKSPACE}/${DOCS_OUTPUT_DIR} |
| 57 | +
|
| 58 | + - name: Publish docs |
| 59 | + run: | |
| 60 | + cd ${GITHUB_WORKSPACE}/${DOCS_BASE_DIR} |
| 61 | + git config --local user.name "Autobuild bot on GitHub Actions" |
| 62 | + git config --local user.email "githubaction-build-bot@example.com" |
| 63 | + git add . |
| 64 | + if [ $(git status -s | wc -l) -eq 0 ]; then echo "nothing to commit"; exit 0; fi |
| 65 | + git commit -m 'update html' |
| 66 | + git push --quiet "https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" gh-pages:gh-pages |
| 67 | +
|
| 68 | + - name: Notify the URL of the built docs |
| 69 | + uses: thollander/actions-comment-pull-request@master |
| 70 | + with: |
| 71 | + message: 'Please check the built documentation!!! https://python.github.io/python-docs-ja/${{ env.PR_BUILD_ID }}' |
| 72 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments