-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (49 loc) · 1.8 KB
/
sync.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Sync Upstream
on:
workflow_dispatch:
# schedule:
# - cron: "22 2 * * *"
jobs:
syncDocs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Reset the default branch with upstream changes
run: |
git remote add upstream https://github.com/zwoo-hq/docs.git
git fetch upstream main:upstream-main
git reset --hard upstream-main
- name: Get current date
id: date
run: echo "DATE=$(date +'%m/%d/%Y')" >> $GITHUB_OUTPUT
- name: Check for unpushed commits
id: check_unpushed
run: |
git fetch origin
echo 'a'
git log origin/main..upstream/main
echo 'b'
git log upstream/main..origin/main
git diff --exit-code || echo "via diff HAS_COMMITS=true"
UNPUSHED=$(git log origin/main..upstream/main)
echo "UNPUSHED=$UNPUSHED"
if [ -z "$UNPUSHED" ]; then
echo "no new commits - aborting pr creation"
echo "HAS_COMMITS=false" >> $GITHUB_OUTPUT
else
echo "new commits found - creating pr"
echo "HAS_COMMITS=true" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: ${{ steps.check_unpushed.outputs.HAS_COMMITS == 'true' }}
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
branch: upstream-changes
branch-suffix: short-commit-hash
assignees: fabiankachlock
title: "chore(sync): with upstream changes"
body: |
# Sync Upstream Changes
Synced changes as of ${{ steps.date.outputs.DATE }}.
This PR is automatically created by the [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action.