Skip to content
Merged
Show file tree
Hide file tree
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
177 changes: 177 additions & 0 deletions .github/workflows/qq-jobs-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: 同步招聘信息

on:
schedule:
- cron: "0 */3 * * *"
workflow_dispatch:
inputs:
probe_only:
description: 只验证腾讯文档完整性,不修改内容
required: false
default: false
type: boolean
accept_source_deletions:
description: 确认将本次缺失记录标记为源表已移除
required: false
default: false
type: boolean

permissions:
actions: write
contents: write
issues: write

concurrency:
group: ${{ github.repository }}-qq-jobs-sync
cancel-in-progress: false

env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
HUGO_VERSION: 0.159.0
PLAYWRIGHT_VERSION: 1.55.0
PYTHONDONTWRITEBYTECODE: "1"

jobs:
sync:
name: 校验、同步并发布
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: 检出最新默认分支
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.repository.default_branch }}
submodules: false

- name: 安装 Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: 还原专用账号会话
shell: bash
env:
QQ_STORAGE_STATE_B64: ${{ secrets.QQ_DOCS_STORAGE_STATE_B64 }}
run: |
if [[ -z "$QQ_STORAGE_STATE_B64" ]]; then
echo "缺少 QQ_DOCS_STORAGE_STATE_B64。" >&2
exit 1
fi
STORAGE_STATE="$RUNNER_TEMP/qq-docs-storage-state.json"
printf '%s' "$QQ_STORAGE_STATE_B64" | base64 --decode > "$STORAGE_STATE"
chmod 600 "$STORAGE_STATE"
STORAGE_STATE="$STORAGE_STATE" \
python3 -c 'import json, os; json.load(open(os.environ["STORAGE_STATE"], encoding="utf-8"))'
echo "STORAGE_STATE=$STORAGE_STATE" >> "$GITHUB_ENV"

- name: 安装 Playwright Chromium
run: |
python3 -m pip install --disable-pip-version-check "playwright==$PLAYWRIGHT_VERSION"
python3 -m playwright install --with-deps chromium

- name: 运行同步测试
run: python3 -m unittest tests.test_sync_qq_jobs

- name: 双遍读取并校验腾讯文档
shell: bash
run: |
args=(
--storage-state "$STORAGE_STATE"
--timeout-seconds 120
)
if [[ "${{ inputs.probe_only || false }}" == "true" ]]; then
args+=(--probe-only)
else
args+=(--check-links)
fi
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.accept_source_deletions || false }}" == "true" ]]; then
args+=(--accept-source-deletions)
fi
python3 scripts/sync_qq_jobs.py "${args[@]}"

- name: 检查生成文件范围
id: changes
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.probe_only) }}
shell: bash
run: |
allowed='^(data/jobs/(daily-updates|early-recruitment)\.json|content/docs/jobs/(每日更新|秋招提前批)\.md)$'
changed_files="$(git -c core.quotepath=false diff --name-only)"
unexpected="$(printf '%s\n' "$changed_files" | sed '/^$/d' | grep -Ev "$allowed" || true)"
if [[ -n "$unexpected" ]]; then
echo "同步产生了白名单外改动:" >&2
echo "$unexpected" >&2
exit 1
fi
if [[ -z "$changed_files" ]]; then
echo "updated=false" >> "$GITHUB_OUTPUT"
else
echo "updated=true" >> "$GITHUB_OUTPUT"
git diff --check -- \
data/jobs/daily-updates.json \
data/jobs/early-recruitment.json \
content/docs/jobs/每日更新.md \
content/docs/jobs/秋招提前批.md
fi

- name: 初始化主题子模块
if: steps.changes.outputs.updated == 'true'
run: git submodule update --init --recursive

- name: 安装 Hugo
if: steps.changes.outputs.updated == 'true'
uses: peaceiris/actions-hugo@v3
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true

- name: 构建整站
if: steps.changes.outputs.updated == 'true'
run: hugo --minify

- name: 校验搜索索引收录
if: steps.changes.outputs.updated == 'true'
run: python3 scripts/check_search_index.py --site public

- name: 提交并推送招聘信息
if: steps.changes.outputs.updated == 'true'
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -- \
data/jobs/daily-updates.json \
data/jobs/early-recruitment.json \
content/docs/jobs/每日更新.md \
content/docs/jobs/秋招提前批.md
git commit -m "更新招聘信息"
git push origin "HEAD:$DEFAULT_BRANCH"

- name: 触发现有 Pages 发布工作流
if: steps.changes.outputs.updated == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run static.yml --ref "$DEFAULT_BRANCH"

report_failure:
name: 报告同步失败
needs: sync
if: ${{ always() && needs.sync.result == 'failure' }}
runs-on: ubuntu-latest
steps:
- name: 创建或更新故障 Issue
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
shell: bash
run: |
title='招聘信息同步失败'
printf -v body '招聘信息同步未通过完整性门槛,现有站点内容保持不变。\n\n运行:%s\n触发方式:%s\n提交:%s' \
"$RUN_URL" "${{ github.event_name }}" "${{ github.sha }}"
issue_number="$(gh issue list --state open --search "$title in:title" --json number,title --jq '.[] | select(.title == "招聘信息同步失败") | .number' | head -n 1)"
if [[ -n "$issue_number" ]]; then
gh issue edit "$issue_number" --body "$body"
else
gh issue create --title "$title" --body "$body"
fi
78 changes: 78 additions & 0 deletions assets/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,84 @@ body.sidebar-collapsed .book-brand-mark {
background: rgba(255, 255, 255, 0.78);
}

.markdown .job-table-scroll {
max-width: 100%;
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 0.25rem;
scrollbar-gutter: stable;
overscroll-behavior-inline: contain;
}

.markdown table.job-table {
width: max-content;
min-width: 100%;
max-width: none;
margin: 0;
table-layout: auto;
}

.markdown table.job-table th,
.markdown table.job-table td {
min-width: 9rem;
vertical-align: top;
white-space: nowrap;
}

.markdown table.job-table th:first-child,
.markdown table.job-table td:first-child {
min-width: 18rem;
}

.markdown table.job-table td a {
display: inline-block;
max-width: 28rem;
overflow-wrap: anywhere;
white-space: normal;
}

.markdown .job-pagination {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
margin-top: 1rem;
}

.markdown .job-pagination button {
display: inline-flex;
width: 2.25rem;
height: 2.25rem;
align-items: center;
justify-content: center;
padding: 0;
border: 1px solid var(--goclub-border);
border-radius: 0.35rem;
background: rgba(var(--goclub-surface-rgb), 0.9);
color: var(--body-font-color);
cursor: pointer;
font: inherit;
font-size: 1.25rem;
line-height: 1;
}

.markdown .job-pagination button:hover,
.markdown .job-pagination button:focus-visible {
border-color: var(--goclub-primary);
color: var(--goclub-primary);
}

.markdown .job-pagination button:disabled {
cursor: default;
opacity: 0.42;
}

.markdown .job-pagination-status {
min-width: 6.5rem;
text-align: center;
font-variant-numeric: tabular-nums;
}

.markdown table tr th {
background: rgba(0, 75, 73, 0.07);
color: var(--body-font-color);
Expand Down
2 changes: 2 additions & 0 deletions content/docs/jobs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ shortlink: "93fk"
## 子栏目

- [内推]({{< relref "referral/_index.md" >}}):社区成员提供的各公司内推码与投递入口。
- [每日更新]({{< relref "每日更新.md" >}}):按更新时间汇总最新招聘公告与投递入口。
- [秋招提前批]({{< relref "秋招提前批.md" >}}):汇总秋招提前批企业与投递入口。
Loading
Loading