Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow: add mirror for DR #13

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/workflow"

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
Loading