forked from dop251/goja
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
34 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 |
---|---|---|
@@ -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 "[email protected]" | ||
|
||
# - 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 |