Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows #114
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: doc | |
on: [push, pull_request] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: "recursive" | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install tox | |
- name: Build Docs | |
run: | | |
tox -e docs | |
- name: Preserve Docs | |
# if: ${{ github.event_name == 'push' }} | |
run: | | |
tar -czvf docs.tar.gz -C docs/_build html rtdpage | |
- name: Save artifact | |
# if: ${{ github.event_name == 'push' }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: docs | |
path: ./docs.tar.gz | |
deploy: | |
name: Deploy | |
needs: build | |
runs-on: ubuntu-latest | |
env: | |
DOCS_REPO: SoCXin/docs | |
DOCS_DIR: docs | |
LATEST_DOCS_DIR: latest-docs | |
RELEASE_BUILD: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- name: Download artifact | |
uses: actions/[email protected] | |
with: | |
name: docs | |
- name: Unpack artifact | |
run: | | |
mkdir ./${{ env.LATEST_DOCS_DIR }} | |
tar -xzf ./docs.tar.gz -C ./${{ env.LATEST_DOCS_DIR }} | |
- name: Delete Artifact | |
uses: geekyeggo/delete-artifact@v1 | |
with: | |
name: docs | |
- name: Select Docs type | |
id: get-destination-dir | |
run: | | |
if [[ ${{ env.RELEASE_BUILD }} == true ]]; then | |
echo "::set-output name=dst_dir::stable" | |
else | |
echo "::set-output name=dst_dir::latest" | |
fi | |
- name: Checkout Docs | |
continue-on-error: true | |
uses: actions/checkout@v2 | |
with: | |
repository: ${{ env.DOCS_REPO }} | |
path: ${{ env.DOCS_DIR }} | |
ref: gh-pages | |
- name: Synchronize Docs | |
run: | | |
rm -rf ${{ env.DOCS_DIR }}/.git | |
cp -rf ${{ env.LATEST_DOCS_DIR }}/html/* ${{ env.DOCS_DIR }}/ | |
if [[ ${{ env.RELEASE_BUILD }} == false ]]; then | |
rm -rf ${{ env.DOCS_DIR }}/page | |
mkdir -p ${{ env.DOCS_DIR }}/page | |
cp -rf ${{ env.LATEST_DOCS_DIR }}/rtdpage/* ${{ env.DOCS_DIR }}/page | |
fi | |
- name: Validate Docs | |
run: | | |
if [ -z "$(ls -A ${{ env.DOCS_DIR }})" ]; then | |
echo "Docs folder is empty. Aborting!" | |
exit 1 | |
fi | |
- name: Deploy Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
personal_token: ${{ secrets.SOC_XIN_TOCKEN }} | |
external_repository: ${{ env.DOCS_REPO }} | |
publish_dir: ./${{ env.DOCS_DIR }} | |
commit_message: Sync Docs |