Skip to content

Loopjet upstream sync #29

Loopjet upstream sync

Loopjet upstream sync #29

name: Loopjet upstream sync
on:
schedule:
- cron: "23 3 * * *"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: upstream-sync-version-16
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
ref: version-16
- name: Sync upstream source
env:
UPSTREAM_REPOSITORY: frappe/hrms
UPSTREAM_BRANCH: version-16
run: |
git config user.name "loopjet-upstream-bot"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote add upstream "https://github.com/$UPSTREAM_REPOSITORY.git"
git fetch upstream "$UPSTREAM_BRANCH"
upstream_ref="upstream/$UPSTREAM_BRANCH"
upstream_sha="$(git rev-parse "$upstream_ref")"
patch_file="$RUNNER_TEMP/upstream-source.patch"
# The repository token cannot update workflow definitions. Keep
# Loopjet's workflows isolated while mirroring all product source.
git diff --binary HEAD "$upstream_ref" -- . \
':(exclude).github/workflows/**' > "$patch_file"
if [[ ! -s "$patch_file" ]]; then
echo "Product source is already current with $UPSTREAM_REPOSITORY@$upstream_sha"
exit 0
fi
git apply --index --binary "$patch_file"
git commit -m "chore(mirror): sync $UPSTREAM_REPOSITORY@$upstream_sha"
git push origin "$UPSTREAM_BRANCH"