Skip to content

Commit 1bdd57b

Browse files
committed
feat: Switch mirror workflow to SSH
1 parent 4d3eb9c commit 1bdd57b

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

.github/workflows/mirror.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,60 @@ permissions: read-all
1313
jobs:
1414
mirror-gitlab:
1515
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
1618
if: ${{ vars.GITLAB_MIRROR_ENABLED == 'true' }}
1719

1820
steps:
1921
- name: Checkout
20-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2123
with:
2224
fetch-depth: 0
2325

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+
2436
- name: Push to GitLab
2537
env:
26-
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
2738
REPO_NAME: ${{ github.event.repository.name }}
2839
run: |
29-
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
3041
git push gitlab HEAD:main --force || git push gitlab HEAD:master --force
3142
git push gitlab --tags --force
3243
3344
mirror-bitbucket:
3445
runs-on: ubuntu-latest
46+
permissions:
47+
contents: read
3548
if: ${{ vars.BITBUCKET_MIRROR_ENABLED == 'true' }}
3649

3750
steps:
3851
- name: Checkout
39-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
52+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4053
with:
4154
fetch-depth: 0
4255

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+
4366
- name: Push to Bitbucket
4467
env:
45-
BITBUCKET_TOKEN: ${{ secrets.BITBUCKET_TOKEN }}
4668
REPO_NAME: ${{ github.event.repository.name }}
4769
run: |
48-
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
4971
git push bitbucket HEAD:main --force || git push bitbucket HEAD:master --force
5072
git push bitbucket --tags --force

0 commit comments

Comments
 (0)