Skip to content

Update update.yaml

Update update.yaml #3

Workflow file for this run

name: Update
on:
workflow_dispatch:
push:
paths:
- '.github/workflows/update.yaml'
schedule:
- cron: '0 16 * * *' # Runs at 16:00 UTC every day, which is 00:00 UTC+8
jobs:
sync-and-modify:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout your repository
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensures history is fetched
# Step 2: Configure Git
- name: Configure Git
run: |
git config user.name 'GitHub Action'
git config user.email '[email protected]'
# Step 3: Add the upstream repository
- name: Add Upstream Remote
run: git remote add upstream https://github.com/RuCu6/Loon.git
# Step 4: Fetch the latest changes from the upstream repository
- name: Fetch Upstream
run: |
git fetch upstream
git checkout main
# Step 5: Merge changes from upstream, favoring their changes in conflicts
- name: Merge Upstream Changes
run: git merge upstream/main --allow-unrelated-histories --strategy-option theirs
# Step 6: Modify files
- name: Modify Files Excluding Markdown Files
run: |
# Step 7: Check for changes and commit if any
- name: Commit and Push Changes
run: |
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Sync from upstream and modify files"
git push origin master
else
echo "No changes to commit"
fi