Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add CI #2

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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
continue-on-error: true
with:
fix: true
globs: "**/*.md"

- name: Determine if a PR should be submitted
if: github.ref == 'refs/heads/master'
id: file_changes
run: |
if [[ -z $(git diff --name-only) ]]; then
echo "::set-output name=should_submit::false"
else
echo "::set-output name=should_submit::true"
fi

- name: Submit PR if mdl changes files
if: steps.file_changes.outputs.should_submit == 'true' && github.ref == 'refs/heads/master'
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
Loading