Skip to content

Commit

Permalink
ci: Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
YDX-2147483647 committed Jan 7, 2024
1 parent 2adb6a5 commit 696ea58
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 5 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deploy

on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
# https://github.com/actions/starter-workflows/blob/main/pages/
concurrency:
group: pages
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Fetch README
uses: actions/checkout@v4
with:
sparse-checkout: |
README.md
sparse-checkout-cone-mode: false
- uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- run: just build-for-pandoc
- name: Convert to HTML
uses: docker://pandoc/core:3
with:
args: >-
index.md
--from gfm
--standalone
--output index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./build

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
49 changes: 44 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,59 @@ python := env_var_or_default('PYTHON','python')

# 列出可用任务
@default:
just --list
just --list

# 安装、升级依赖
bootstrap:
{{ python }} -m pip install --upgrade ruamel.yaml
{{ python }} -m pip install --upgrade ruamel.yaml

# 同步类别
sync-categories *ARGS:
{{ python }} ./scripts/sync_categories.py ./projects.yaml ./.github/ISSUE_TEMPLATE/01_suggest-project.yml {{ ARGS }}
{{ python }} ./scripts/sync_categories.py ./projects.yaml ./.github/ISSUE_TEMPLATE/01_suggest-project.yml {{ ARGS }}

# 列出项目添加请求
list-project-suggestions:
gh issue list --label add-project
gh issue list --label add-project

# 从 issue 添加项目
add-project ISSUE_NUMBER:
gh issue view {{ ISSUE_NUMBER }} --json body | {{ python }} ./scripts/add_project.py ./projects.yaml
gh issue view {{ ISSUE_NUMBER }} --json body | {{ python }} ./scripts/add_project.py ./projects.yaml

# 用`README.md`构建可用于`pandoc --from gfm`的`build/index.md`
build-for-pandoc:
#!/usr/bin/env sh
set -euxo pipefail
rm -rf build
mkdir -p build
cd build

# Write metadata
cat > index.md <<- "EOF"
---
title: best-of-BITs (bytes)
lang: zh-CN
header-includes: |
<style>
details {
margin-top: 1em;
}
li {
margin-top: 0.2em;
}
.note {
border-left: 0.25em solid #004daa;
padding-left: 1em;
}
.note > .title {
color: #004daa;
}
</style>
---
EOF

# Delete `<h1>` and unnecessary buttons
cat ../README.md \
| sed '1,5d' \
| grep --invert-match '<a href="#contents">.* alt="Back to top"></a>' \
>> index.md

0 comments on commit 696ea58

Please sign in to comment.