From 02a0f871e0574bf05bfd6b1220aba393fb39f6ac Mon Sep 17 00:00:00 2001 From: bobo Date: Wed, 3 Jan 2024 14:59:35 +0800 Subject: [PATCH 1/4] type: feat: Add sync workflow to GitLab - Implement workflow for syncing GitHub repo with GitLab - Setup GitHub action to checkout, configure Git, and add remote - Use retry action to fetch, rebase, and push to GitLab repository --- .github/workflows/sync-to-gitlab.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/sync-to-gitlab.yml diff --git a/.github/workflows/sync-to-gitlab.yml b/.github/workflows/sync-to-gitlab.yml new file mode 100644 index 0000000..bae7116 --- /dev/null +++ b/.github/workflows/sync-to-gitlab.yml @@ -0,0 +1,26 @@ +jobs: + sync: + runs-on: ubuntu-latest + steps: + - name: Checkout GitHub repository + uses: actions/checkout@v4 + + - name: Setup Git + run: | + git config user.name "bobo" + git config user.email "bobo.yang@merico.dev" + + - name: Add GitLab remote + run: | + # 使用环境变量中的访问令牌来设置GitLab远程仓库的URL + git remote add gitlab https://oauth2:${{ secrets.GITLAB_ACCESS_TOKEN }}@gitlab.com/devchat-ai/workflows.git + + - name: Retry Command + uses: nick-invision/retry@v4 + with: + timeout_minutes: 10 + max_attempts: 3 + command: | + git fetch gitlab && + git rebase gitlab/main && + git push gitlab \ No newline at end of file From 6e7c9e7bedd8eda2e36d219e46f7d05365f48c2a Mon Sep 17 00:00:00 2001 From: bobo Date: Wed, 3 Jan 2024 14:59:35 +0800 Subject: [PATCH 2/4] type: ci: Add sync workflow for GitLab - Add a new GitHub Actions workflow for syncing to GitLab - Trigger the workflow on push to the main branch - Remove commented out code for setting GitLab remote URL --- .github/workflows/sync-to-gitlab.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-to-gitlab.yml b/.github/workflows/sync-to-gitlab.yml index bae7116..1ad0a82 100644 --- a/.github/workflows/sync-to-gitlab.yml +++ b/.github/workflows/sync-to-gitlab.yml @@ -1,3 +1,10 @@ +name: Sync to GitLab + +on: + push: + branches: + - main + jobs: sync: runs-on: ubuntu-latest @@ -12,7 +19,6 @@ jobs: - name: Add GitLab remote run: | - # 使用环境变量中的访问令牌来设置GitLab远程仓库的URL git remote add gitlab https://oauth2:${{ secrets.GITLAB_ACCESS_TOKEN }}@gitlab.com/devchat-ai/workflows.git - name: Retry Command From a28b3d676bf053ebdf366f02371e423ba697fee6 Mon Sep 17 00:00:00 2001 From: bobo Date: Wed, 3 Jan 2024 14:59:35 +0800 Subject: [PATCH 3/4] ci: Downgrade nick-invision/retry action to v2 - Downgrade the GitHub action nick-invision/retry to version 2 - This change addresses compatibility issues with the workflow --- .github/workflows/sync-to-gitlab.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-to-gitlab.yml b/.github/workflows/sync-to-gitlab.yml index 1ad0a82..166cb7b 100644 --- a/.github/workflows/sync-to-gitlab.yml +++ b/.github/workflows/sync-to-gitlab.yml @@ -22,7 +22,7 @@ jobs: git remote add gitlab https://oauth2:${{ secrets.GITLAB_ACCESS_TOKEN }}@gitlab.com/devchat-ai/workflows.git - name: Retry Command - uses: nick-invision/retry@v4 + uses: nick-invision/retry@v2 with: timeout_minutes: 10 max_attempts: 3 From 328af00e419b9c666cd808264404acf6fd00f86f Mon Sep 17 00:00:00 2001 From: bobo Date: Wed, 3 Jan 2024 15:32:07 +0800 Subject: [PATCH 4/4] use gh-action as user name --- .github/workflows/sync-to-gitlab.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-to-gitlab.yml b/.github/workflows/sync-to-gitlab.yml index 166cb7b..b3433f6 100644 --- a/.github/workflows/sync-to-gitlab.yml +++ b/.github/workflows/sync-to-gitlab.yml @@ -14,8 +14,8 @@ jobs: - name: Setup Git run: | - git config user.name "bobo" - git config user.email "bobo.yang@merico.dev" + git config user.name "gh-action" + git config user.email "gh-action@merico.dev" - name: Add GitLab remote run: |