Skip to content

Commit 7e2d06d

Browse files
committed
feat: Switch mirror workflow to SSH
1 parent 946231b commit 7e2d06d

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

.github/workflows/mirror.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,21 @@ jobs:
2323
with:
2424
fetch-depth: 0
2525

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+
2636
- name: Push to GitLab
2737
env:
28-
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
2938
REPO_NAME: ${{ github.event.repository.name }}
3039
run: |
31-
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
3241
git push gitlab HEAD:main --force || git push gitlab HEAD:master --force
3342
git push gitlab --tags --force
3443
@@ -44,11 +53,20 @@ jobs:
4453
with:
4554
fetch-depth: 0
4655

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+
4766
- name: Push to Bitbucket
4867
env:
49-
BITBUCKET_TOKEN: ${{ secrets.BITBUCKET_TOKEN }}
5068
REPO_NAME: ${{ github.event.repository.name }}
5169
run: |
52-
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
5371
git push bitbucket HEAD:main --force || git push bitbucket HEAD:master --force
5472
git push bitbucket --tags --force

0 commit comments

Comments
 (0)