From f7ab369d476ec2729b3aceb19ccc336ce4b04adf Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Thu, 1 Aug 2024 17:22:43 +0200 Subject: [PATCH 1/4] First attempt at mirroring to gitlab --- .github/workflows/mirror_to_gitlab.yaml | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/mirror_to_gitlab.yaml diff --git a/.github/workflows/mirror_to_gitlab.yaml b/.github/workflows/mirror_to_gitlab.yaml new file mode 100644 index 0000000000..bbb731759d --- /dev/null +++ b/.github/workflows/mirror_to_gitlab.yaml @@ -0,0 +1,55 @@ +name: Mirror to GitLab + +on: + push: + delete: + workflow_dispatch: # This enables manual triggering + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - name: Wait for other instances of this workflow to conclude + uses: softprops/turnstyle@8db075d65b19bf94e6e8687b504db69938dc3c65 + with: + same-branch-only: 'true' + abort-after-seconds: 300 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + fetch-depth: 0 # Fetch full history + + - name: Set up Git + run: | + git config --global user.name 'GitHub Action' + git config --global user.email 'action@github.com' + + - name: Set up SSH + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Add GitLab public keys + run: | + ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts + + - name: Sync and commit changes + id: sync-and-commit + run: | + git lfs pull + + # Add GitLab remote + git remote add gitlab git@gitlab.com:sunnypilot/public/sunnypilot.git + + # Fetch from GitLab and check if the branch exists + if git fetch gitlab ${{ github.ref }}; then + # Merge changes from GitLab if the branch exists + git merge gitlab/${{ github.ref_name }} --allow-unrelated-histories --strategy-option=theirs + else + echo "Branch does not exist on GitLab, skipping merge." + fi + git push -u gitlab ${{ github.ref }} # If you have issues with "push rejected missing LFS" or something. Make sure you disabled LFS on the GITLAB repo if you intend to use a different LFS repo other than the target repo \ No newline at end of file From cd0ee087634802a18ee1f9ab3ba974de19f24d20 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Thu, 1 Aug 2024 18:10:59 +0200 Subject: [PATCH 2/4] Allow auto publishing of public prebuilts --- .gitlab-ci.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1fe0226cc..6ea0c3b70b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,6 +47,7 @@ workflow: # If running on any branch other than main. variables: EXTRA_VERSION_IDENTIFIER: "-${CI_PIPELINE_IID}" NEW_BRANCH: "dev-c3" + AUTO_PUBLISH: true when: always #commit made to main (master) - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH @@ -54,6 +55,7 @@ workflow: # If running on any branch other than main. NEW_BRANCH: "staging-c3" VERSION: 'cat common/version.h | grep COMMA_VERSION | sed -e "s/[^0-9|.]//g"' EXTRA_VERSION_IDENTIFIER: "-staging" + AUTO_PUBLISH: true when: always # if tag - if: $CI_COMMIT_TAG @@ -61,6 +63,7 @@ workflow: # If running on any branch other than main. NEW_BRANCH: "release-c3" VERSION: 'cat common/version.h | grep COMMA_VERSION | sed -e "s/[^0-9|.]//g"' EXTRA_VERSION_IDENTIFIER: "-release" + AUTO_PUBLISH: true - when: always @@ -92,7 +95,7 @@ build: - sed -i '/from .board.jungle import PandaJungle, PandaJungleDFU/s/^/#/' panda/__init__.py # comment panda jungle when prebuilt - scons -j$(nproc) cache_dir=${CI_DIR}/scons_cache --minimal - touch ${BUILD_DIR}/prebuilt - - sudo rm -rf ${OUTPUT_DIR} + - sudo rm -rf ${OUTPUT_DIR} - mkdir -p ${OUTPUT_DIR} # We first include the paths we want to keep, even if we later will be excluding the other things on those paths - rsync -avm @@ -135,7 +138,7 @@ build: --chown=comma:comma ${BUILD_DIR}/ ${OUTPUT_DIR}/ after_script: - # cleanup build dir after doing work + # cleanup build dir after doing work - find $BUILD_DIR/ -mindepth 1 -delete artifacts: paths: @@ -146,7 +149,7 @@ build: when: manual - if: $NEW_BRANCH when: always - + check no source code sent: image: alpine stage: sanity @@ -215,6 +218,8 @@ publish to public github prebuilt: GIT_CONFIG_USER_EMAIL: "jason.wen@sunnypilot.ai" GIT_CONFIG_USER_NAME: "Jason Wen" rules: + - if: $AUTO_PUBLISH + when: on_success - if: $NEW_BRANCH when: manual - when: never From fb7076a042f44389c65499d38b8832b018260648 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Thu, 1 Aug 2024 18:28:15 +0200 Subject: [PATCH 3/4] Change remote --- .github/workflows/mirror_to_gitlab.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mirror_to_gitlab.yaml b/.github/workflows/mirror_to_gitlab.yaml index bbb731759d..e605458ad9 100644 --- a/.github/workflows/mirror_to_gitlab.yaml +++ b/.github/workflows/mirror_to_gitlab.yaml @@ -43,7 +43,7 @@ jobs: git lfs pull # Add GitLab remote - git remote add gitlab git@gitlab.com:sunnypilot/public/sunnypilot.git + git remote add gitlab git@gitlab.com:sunnypilot/sunnyhaibin/sunnypilot-github-mirror.git # Fetch from GitLab and check if the branch exists if git fetch gitlab ${{ github.ref }}; then From f311c8b1d7f6de46b25c10a2a8dbb64d002e8d60 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Thu, 1 Aug 2024 20:09:17 +0200 Subject: [PATCH 4/4] No auto publish for dev-c3 or release-c3 --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6ea0c3b70b..33d6289f63 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,7 +47,6 @@ workflow: # If running on any branch other than main. variables: EXTRA_VERSION_IDENTIFIER: "-${CI_PIPELINE_IID}" NEW_BRANCH: "dev-c3" - AUTO_PUBLISH: true when: always #commit made to main (master) - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH @@ -63,7 +62,6 @@ workflow: # If running on any branch other than main. NEW_BRANCH: "release-c3" VERSION: 'cat common/version.h | grep COMMA_VERSION | sed -e "s/[^0-9|.]//g"' EXTRA_VERSION_IDENTIFIER: "-release" - AUTO_PUBLISH: true - when: always