forked from LemmyNet/lemmy-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GHA workflow to sync fork with upstream changes
- Loading branch information
1 parent
407d1dd
commit 1287827
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Sync fork | ||
|
||
on: | ||
schedule: | ||
- cron: "41 19 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
sync: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: Checkout current fork HEAD | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
show-progress: false | ||
|
||
- name: Set up upstream git remote | ||
run: | | ||
upstream="$(gh repo view "${{ github.repository }}" --json parent --jq '.parent.owner.login + "/" + .parent.name')" | ||
echo "upstream=$upstream" | ||
git remote add upstream "https://github.com/$upstream.git" | ||
git fetch upstream "${{ github.event.repository.default_branch }}" | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
|
||
- name: Determine number of missing commits from usptream | ||
id: check-missing-commits | ||
run: | | ||
upstream_commit_count="$(git rev-list --count "$GITHUB_REF_NAME..upstream/${{ github.event.repository.default_branch }}")" | ||
echo "commit-count=$upstream_commit_count" | tee -a "$GITHUB_OUTPUT" | ||
- name: Rebase and push | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git rebase --committer-date-is-author-date "upstream/${{ github.event.repository.default_branch }}" | ||
git push --force | ||
if: >- | ||
fromJSON(steps.check-missing-commits.outputs.commit-count) > 0 |