From 567c0f5d1c440aa5e155c7a46d0f0ab816128ec6 Mon Sep 17 00:00:00 2001 From: solethu Date: Sat, 14 Sep 2024 11:54:18 +0200 Subject: [PATCH] lu: add mirror for DR (#29) --- .github/workflows/mirror-to-codecommit.yml | 39 ++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/mirror-to-codecommit.yml create mode 100644 .gitignore diff --git a/.github/workflows/mirror-to-codecommit.yml b/.github/workflows/mirror-to-codecommit.yml new file mode 100644 index 0000000..789c81b --- /dev/null +++ b/.github/workflows/mirror-to-codecommit.yml @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file