Update Activity API #8037
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Activity API | |
on: | |
push: | |
paths: | |
- "scripts/build_activity_json.py" | |
- "scripts/sync_to_gitee.sh" | |
workflow_dispatch: | |
schedule: | |
- cron: "0 */2 * * *" | |
if: github.ref == 'refs/heads/main' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./scripts | |
environment: API | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- uses: actions/cache@v3 | |
name: Configure pip caching | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Python dependencies | |
run: | | |
python -m pip install -r requirements.txt | |
- name: Update Activity JSON | |
env: | |
APP_TOKEN: ${{ secrets.APP_TOKEN }} | |
APP_ID: ${{ secrets.APP_ID }} | |
APP_SECRET: ${{ secrets.APP_SECRET }} | |
run: |- | |
python ./build_activity_json.py | |
- name: Update Topics JSON | |
env: | |
APP_TOKEN: ${{ secrets.APP_TOKEN }} | |
APP_ID: ${{ secrets.APP_ID }} | |
APP_SECRET: ${{ secrets.APP_SECRET }} | |
run: |- | |
python ./build_topic_json.py | |
- name: Install jq for Bash | |
run: sudo apt-get update && sudo apt-get install -y jq | |
- name: Update Gitee File | |
env: | |
GITEE_ACCESS_TOKEN: ${{ secrets.GITEE_ACCESS_TOKEN }} | |
run: | | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
git checkout $BRANCH_NAME | |
if [[ $BRANCH_NAME == "main" ]]; then | |
sh ./sync_to_gitee.sh | |
else | |
sh ./sync_to_gitee.sh dev | |
fi | |
shell: bash | |
- name: Commit and push if changed | |
run: |- | |
git diff | |
git config --global user.email "curly230304@163.com" | |
git config --global user.name "curly_bot" | |
git pull origin $BRANCH_NAME | |
git add -A | |
git commit -m "Update activity.json" || exit 0 | |
git push origin $BRANCH_NAME |