Skip to content

feat: commit all diffs (#4) #3

feat: commit all diffs (#4)

feat: commit all diffs (#4) #3

name: Sync archive to master
on:
push:
branches:
- archive
jobs:
create-pull-request:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Filter and copy files
run: |
# Create a temporary directory for syncing files
mkdir -p /tmp/sync_dir
# Switch to archive branch and copy files excluding .git and .xz files
git checkout archive
rsync -av --exclude='.git' --exclude='*.xz' ./ /tmp/sync_dir/
# Switch to master branch
git checkout master
# Sync files to the master working tree
rsync -av --delete --exclude='.git' /tmp/sync_dir/ ./
# Check for changes
if git diff --quiet; then
echo "No changes to commit."
echo "no_changes=true" >> $GITHUB_ENV
else
echo "Changes detected."
git add -A
git commit -m "Sync files from archive branch (excluding .xz files)"
echo "no_changes=false" >> $GITHUB_ENV
fi
- name: Create Pull Request Branch
if: env.no_changes == 'false'
run: |
# Generate a unique branch name to avoid conflicts
BRANCH_NAME="archive-sync-$(date +%s)"
git checkout -b $BRANCH_NAME
git push origin $BRANCH_NAME
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
- name: Create Pull Request
if: env.no_changes == 'false'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.branch_name }}
base: master
title: "Sync files from archive branch (excluding .xz files)"
body: |
This pull request syncs files from the `archive` branch to the `master` branch.
**Note**: Files with the `.xz` extension are excluded.