-
Notifications
You must be signed in to change notification settings - Fork 12
66 lines (58 loc) · 1.85 KB
/
sync-mastodon-status.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Sync mastodon status
on:
# schedule:
# - cron: "0 17 * * *"
# watch:
# types: [started]
workflow_dispatch:
repository_dispatch:
types: [mastodon-update]
jobs:
mastodon:
name: Fetch mastodon status
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# 检查是否安装了 JQ
- name: Check JQ
run: |
if ! command -v jq &> /dev/null; then
echo "jq is not installed. Installing..."
sudo apt-get update
sudo apt-get install -y jq
else
echo "jq is already installed."
fi
# 把当前目录保存到环境变量中
echo "WORK_DIR=$(pwd)" >> $GITHUB_ENV
# 下载最新的 Mastodon
- name: Download Mastodon Status
run: |
cd assets/data/mastodon/
rm mastodon.json
url="https://e5n.cc/api/v1/accounts/111136231674527355/statuses?limit=20&exclude_replies=true&exclude_reblogs=true"
output="mastodon.json"
curl -s "$url" >"$output"
echo "TAG_NAME=$(jq -r '.[0].tags[0].name' mastodon.json)" >> $GITHUB_ENV
# 把修改后的数据提交到 GitHub 仓库
- name: Git Add and Commit
uses: EndBug/add-and-commit@v9
with:
message: 'chore(data): fetch mastodon status'
committer_name: 'github-actions[bot]'
committer_email: 'github-actions[bot]@users.noreply.github.com'
add: |
'./assets/data/mastodon'
# 调用另外的 GitHub Actions
- name: Sync NeoDB Data
if: ${{ env.TAG_NAME == 'NeoDB' }}
uses: peter-evans/repository-dispatch@v3
with:
event-type: sync-neodb
# 调用另外的 GitHub Actions 构建 Hugo
- name: Build Hugo and Deploy
if: ${{ env.TAG_NAME != 'NeoDB' }}
uses: peter-evans/repository-dispatch@v3
with:
event-type: build-hugo