Skip to content

mastodon-update

mastodon-update #20

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 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: |
'./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