Skip to content

Commit

Permalink
lu: add mirror for DR (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
solethus authored Sep 14, 2024
1 parent 976ff15 commit 567c0f5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/mirror-to-codecommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Mirror to CodeCommit

on:
push:
branches:
- main

jobs:
mirror_to_codecommit:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Mirror to CodeCommit
env:
AWS_HTTPS_USERNAME: ${{secrets.AWS_HTTPS_USERNAME}}
AWS_HTTPS_PASSWORD: ${{secrets.AWS_HTTPS_PASSWORD}}
AWS_REGION: ${{secrets.AWS_REGION}}
run: |
# URL encode the username and password
USERNAME_ENCODED=$(python -c "import urllib.parse; print(urllib.parse.quote('$AWS_HTTPS_USERNAME', safe=''))")
PASSWORD_ENCODED=$(python -c "import urllib.parse; print(urllib.parse.quote('$AWS_HTTPS_PASSWORD', safe=''))")
# Set up the remote with encoded credentials
CODECOMMIT_URL="https://${USERNAME_ENCODED}:${PASSWORD_ENCODED}@git-codecommit.${AWS_REGION}.amazonaws.com/v1/repos/lu"
git remote add codecommit "$CODECOMMIT_URL"
# Push all branches and tags
git push codecommit --all --force
git push codecommit --tags --force
# Clean up to avoid leaking credentials
git remote remove codecommit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea

0 comments on commit 567c0f5

Please sign in to comment.