Skip to content

Commit

Permalink
fix push to mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
xgui3783 committed Feb 21, 2024
1 parent b79b634 commit 86b87da
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/push-to-mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ name: '[mirror] push to mirror'

on:
push:
branches:
- master
tags:
'**'
workflow_run:
workflows: ["test configuration"]
branches: [master]
types:
- completed
branches: ["master"]
tags: ["*"]

env:
EBRAINS_GITLAB_HOST: ${{ vars.EBRAINS_GITLAB_HOST }}
EBRAINS_GITLAB_REPO: ri/tech-hub/apps/siibra/siibra-configurations-mirror.git

jobs:
# n.b. we use access token, rather than https://github.com/valtech-sd/git-sync
# because it does not seem possible to add project wide ssh key
# and using personal key is not very flesible
push_to_mirror:
if: ${{ env.EBRAINS_GITLAB_HOST != '' }}
runs-on: ubuntu-latest
environment: gitlab_mirror
steps:
Expand All @@ -24,13 +25,13 @@ jobs:
git config --global user.email "[email protected]"
git config --global user.name "inm1 bda - gitlab bot"
mkdir -p ~/.ssh
ssh-keyscan $GITLAB_MIRROR_HOST >> gitlab-known-hosts
ssh-keyscan ${{ env.GITLAB_MIRROR_HOST }} >> gitlab-known-hosts
cat gitlab-known-hosts >> ~/.ssh/known_hosts
- name: script
run: |
git fetch --tags -f
git fetch origin master
if ! git ls-remote ebrains > /dev/null; then git remote add ebrains https://jugitpusher:${GITLAB_MIRROR_TOKEN}@${GITLAB_MIRROR_HOST}/${GITLAB_MIRROR_REPO_PATH}; fi
if ! git ls-remote ebrains > /dev/null; then git remote add ebrains https://jugitpusher:${{ secrets.EBRAINS_GITLAB_PUSH_TOKEN }}@${{ env.GITLAB_MIRROR_HOST }}/${{ env.EBRAINS_GITLAB_REPO }}; fi
git push ebrains --tags -f
git push ebrains HEAD:master -f

0 comments on commit 86b87da

Please sign in to comment.