ops/virtualization: LUG Planet link #638
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 | |
on: | |
- pull_request | |
- push | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
commit-info: ${{ steps.commit-info.outputs.COMMIT_INFO }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
pip3 install \ | |
-r requirements.txt \ | |
-r requirements-ci.txt | |
- name: "Linting: autocorrect" | |
continue-on-error: true | |
run: | | |
curl -fsSL https://raw.githubusercontent.com/huacnlee/autocorrect/main/install | sh | |
autocorrect --fix | |
- name: "Linting: markdownlint-cli2 Part 1" | |
uses: DavidAnson/markdownlint-cli2-action@v15 | |
continue-on-error: true | |
with: | |
fix: true | |
globs: | | |
docs/**/*.md | |
README.md | |
- name: "Linting: markdownlint-cli2 Part 2" | |
uses: DavidAnson/markdownlint-cli2-action@v15 | |
continue-on-error: true | |
with: | |
fix: true | |
globs: | | |
docs/**/*.md | |
README.md | |
- name: Stop and report errors | |
run: | | |
git add -A | |
if ! git diff-index --quiet --cached HEAD --; then | |
echo "Stop." | |
exit 1 | |
fi | |
- name: Build docs | |
run: | | |
mkdocs -v build | |
: > site/.nojekyll | |
echo -n '201.ustclug.org' > site/CNAME | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: site | |
- name: Generate commit info | |
id: commit-info | |
run: | | |
git log -1 --pretty="COMMIT_INFO=%an: [%h] %s" >> "$GITHUB_OUTPUT" | |
deploy: | |
needs: build | |
if: github.ref == 'refs/heads/master' | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v5 | |
with: | |
name: github-pages | |
path: site/ | |
- name: Push site to gh-pages branch | |
run: | | |
git clone --depth=1 --branch=gh-pages --single-branch --no-checkout \ | |
"https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git" test | |
mv test/.git site/.git && rmdir test/ | |
pushd site/ &>/dev/null | |
if [ -f artifact.tar ]; then | |
tar xf artifact.tar | |
rm artifact.tar | |
fi | |
git add -A | |
git -c user.name=GitHub -c [email protected] commit \ | |
-m "Auto deploy from GitHub Actions build ${GITHUB_RUN_NUMBER}" \ | |
-m "${{ needs.build.outputs.commit-info }}" \ | |
--allow-empty | |
git push | |
popd &>/dev/null |