diff --git a/.github/workflows/sync_upstream.yml b/.github/workflows/sync_upstream.yml index 63a2d618..6d7609af 100644 --- a/.github/workflows/sync_upstream.yml +++ b/.github/workflows/sync_upstream.yml @@ -1,47 +1,16 @@ name: Sync with Goja Repository +# on: +# schedule: +# - cron: "0 0 * * 1" # This will run at 00:00 every Monday on: push: branches: test-sync-action - # schedule: - # - cron: "0 0 * * 1" # This will run at 00:00 every Monday jobs: sync: runs-on: ubuntu-latest - # steps: - # - name: Checkout repository - # uses: actions/checkout@v3 - - # - name: Configure Git User - # run: | - # git config user.name "GitHub Actions Bot" - # git config user.email "actions@github.com" - - # - name: Add Goja Remote - # run: | - # git remote add goja https://github.com/dop251/goja.git - - # - name: Fetch Goja Repository - # run: | - # git fetch goja - - # - name: Check for New Commits - # id: check_commits - # run: | - # if git rev-parse HEAD..goja/master | grep -q "."; then - # echo "::set-output name=has_new_commits::true" - # else - # echo "::set-output name=has_new_commits::false" - # fi - - # - name: Merge Changes if Any - # if: steps.check_commits.outputs.has_new_commits == 'true' - # run: | - # git merge --allow-unrelated-histories goja/master - # git remote set-url origin https://x-access-token:${{ secrets.MY_PAT }}@github.com/Gabri3l/goja.git - # git push origin test-sync-action steps: - name: Checkout test-sync-action branch uses: actions/checkout@v3 @@ -58,18 +27,31 @@ jobs: git remote add original https://github.com/dop251/goja.git git fetch original + - name: Check for new commits + id: check_commits + run: | + if git rev-list --count HEAD..original/master | grep -qvE '^0$'; then + echo "::set-output name=new_commits::true" + else + echo "::set-output name=new_commits::false" + fi + - name: Merge changes from original goja master + if: steps.check_commits.outputs.new_commits == 'true' run: | git merge --allow-unrelated-histories original/master - name: Ensure .yml file remains + if: steps.check_commits.outputs.new_commits == 'true' run: | git checkout test-sync-action -- .github/workflows/sync_upstream.yml - name: Set remote using PAT + if: steps.check_commits.outputs.new_commits == 'true' run: | git remote set-url origin https://x-access-token:${{ secrets.MY_PAT }}@github.com/Gabri3l/goja.git - name: Push updates + if: steps.check_commits.outputs.new_commits == 'true' run: | git push origin test-sync-action