1+ # SPDX-License-Identifier: AGPL-3.0-or-later
12name : Mirror to GitLab and Bitbucket
23
34on :
@@ -12,38 +13,60 @@ permissions: read-all
1213jobs :
1314 mirror-gitlab :
1415 runs-on : ubuntu-latest
16+ permissions :
17+ contents : read
1518 if : ${{ vars.GITLAB_MIRROR_ENABLED == 'true' }}
1619
1720 steps :
1821 - name : Checkout
19- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+ uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2023 with :
2124 fetch-depth : 0
2225
26+ - name : Setup SSH
27+ uses : webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0
28+ with :
29+ ssh-private-key : ${{ secrets.GITLAB_SSH_KEY }}
30+
31+ - name : Add GitLab to known hosts
32+ run : |
33+ mkdir -p ~/.ssh
34+ ssh-keyscan -t ed25519 gitlab.com >> ~/.ssh/known_hosts
35+
2336 - name : Push to GitLab
2437 env :
25- GITLAB_TOKEN : ${{ secrets.GITLAB_TOKEN }}
2638 REPO_NAME : ${{ github.event.repository.name }}
2739 run : |
28- git remote add gitlab https://oauth2:${GITLAB_TOKEN} @gitlab.com/ hyperpolymath/${REPO_NAME}.git || true
40+ git remote add gitlab git @gitlab.com: hyperpolymath/${REPO_NAME}.git || true
2941 git push gitlab HEAD:main --force || git push gitlab HEAD:master --force
3042 git push gitlab --tags --force
3143
3244 mirror-bitbucket :
3345 runs-on : ubuntu-latest
46+ permissions :
47+ contents : read
3448 if : ${{ vars.BITBUCKET_MIRROR_ENABLED == 'true' }}
3549
3650 steps :
3751 - name : Checkout
38- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
52+ uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
3953 with :
4054 fetch-depth : 0
4155
56+ - name : Setup SSH
57+ uses : webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0
58+ with :
59+ ssh-private-key : ${{ secrets.BITBUCKET_SSH_KEY }}
60+
61+ - name : Add Bitbucket to known hosts
62+ run : |
63+ mkdir -p ~/.ssh
64+ ssh-keyscan -t ed25519 bitbucket.org >> ~/.ssh/known_hosts
65+
4266 - name : Push to Bitbucket
4367 env :
44- BITBUCKET_TOKEN : ${{ secrets.BITBUCKET_TOKEN }}
4568 REPO_NAME : ${{ github.event.repository.name }}
4669 run : |
47- git remote add bitbucket https://x-token-auth:${BITBUCKET_TOKEN} @bitbucket.org/ hyperpolymath/${REPO_NAME}.git || true
70+ git remote add bitbucket git @bitbucket.org: hyperpolymath/${REPO_NAME}.git || true
4871 git push bitbucket HEAD:main --force || git push bitbucket HEAD:master --force
4972 git push bitbucket --tags --force
0 commit comments