-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip3 install -r requirements.txt | ||
- uses: DavidAnson/markdownlint-cli2-action@v15 | ||
with: | ||
globs: "**/*.md" | ||
|
||
- name: Determine if any docs have changed | ||
id: docs_changed | ||
run: | | ||
git diff --name-only origin/master | grep -qE '^docs/' && echo "true" || echo "false" | ||
- name: Submit PR if mdl changes files | ||
if: steps.docs_changed.outputs.docs_changed == 'true' | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
commit-message: "MarkdownLint auto fix from GitHub Actions run ${{ github.run_number }}" | ||
assignees: "${{ github.actor }}" | ||
branch: mdl-auto-fix | ||
delete-branch: true | ||
title: "Fix MarkdownLint formatting from GitHub Actions run ${{ github.run_number }}" | ||
body: | | ||
Attempt to automatically fix MarkdownLint formatting issues in ${{ github.sha }}. | ||
This PR is generated by GitHub Actions [run ${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). Please choose **Squash and Merge** for this PR. | ||
- name: Build docs | ||
run: | | ||
mkdocs -v build | ||
: > site/.nojekyll | ||
echo -n '201.ustclug.org' > site/CNAME | ||
- name: Deploy to GitHub Pages | ||
if: github.ref == 'refs/heads/master' | ||
run: | | ||
CINFO="$(git log -1 --pretty="%an: [%h] %s")" | ||
git clone --depth=1 --branch=gh-pages --single-branch --no-checkout \ | ||
"https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" test | ||
mv test/.git site/.git && rmdir test/ | ||
pushd site/ &>/dev/null | ||
git add -A | ||
git -c user.name=GitHub -c [email protected] commit \ | ||
-m "Auto deploy from GitHub Actions build ${GITHUB_RUN_NUMBER}" \ | ||
-m "$CINFO" | ||
git push | ||
popd &>/dev/null |