-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working commit for [KDEV-51592] add code commit [MASS PR]
- Loading branch information
Showing
1 changed file
with
33 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,33 +28,40 @@ jobs: | |
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: '0' # Fetch all history for branches and tags | ||
|
||
- name: Configure Git for AWS CodeCommit | ||
run: | | ||
# Set up Git to use HTTPS credentials | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
git config --global credential.helper store | ||
# Store CodeCommit credentials | ||
CODECOMMIT_USER_TRIMMED=$(echo "${{ secrets.CODECOMMIT_USER }}" | xargs) | ||
CODECOMMIT_PASSWORD_TRIMMED=$(echo "${{ secrets.CODECOMMIT_PASSWORD }}" | xargs) | ||
echo "https://${CODECOMMIT_USER_TRIMMED}:${CODECOMMIT_PASSWORD_TRIMMED}@git-codecommit.us-east-1.amazonaws.com" > ~/.git-credentials | ||
- name: Echo the AWS CodeCommit Repository URL | ||
|
||
- name: Configure Git | ||
run: | | ||
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $2}') | ||
echo "Pushing to repository URL: https://git-codecommit.us-east-1.amazonaws.com/v1/repos/$REPO_NAME" | ||
git config --global user.name "gh-backup" | ||
git config --global user.email "action@github.com" | ||
- name: Mirror to AWS CodeCommit | ||
- name: Backup to CodeCommit | ||
env: | ||
GITHUB_REMOTE_NAME: origin | ||
CC_USER: ${{ secrets.CODECOMMIT_USER }} | ||
CC_PASS: ${{ secrets.CODECOMMIT_PASSWORD }} | ||
run: | | ||
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $2}') | ||
GIT_TRACE=1 GIT_CURL_VERBOSE=1 | ||
git fetch origin | ||
git branch -a # Lists all local and remote-tracking branches | ||
git checkout master | ||
git pull origin master | ||
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $2}') | ||
CC_REPO_URL="git-codecommit.us-east-1.amazonaws.com/v1/repos/$REPO_NAME" | ||
CODECOMMIT_URL="https://${CC_USER}:${CC_PASS//@/%40}@${CC_REPO_URL}" | ||
if git remote | grep -q codecommit; then | ||
git remote set-url codecommit "${CODECOMMIT_URL}" | ||
else | ||
git remote add codecommit "${CODECOMMIT_URL}" | ||
fi | ||
git push --mirror --force https://git-codecommit.us-east-1.amazonaws.com/v1/repos/$REPO_NAME | ||
git fetch ${GITHUB_REMOTE_NAME} | ||
git branch -r | grep "${GITHUB_REMOTE_NAME}/" | grep -v '\->' | sed "s/${GITHUB_REMOTE_NAME}\///" | while read branch; do | ||
echo "Processing branch: $branch" | ||
if ! git rev-parse --verify "$branch" >/dev/null 2>&1; then | ||
git checkout -b "$branch" "${GITHUB_REMOTE_NAME}/$branch" | ||
else | ||
git checkout "$branch" | ||
fi | ||
git push codecommit "$branch":"$branch" --force | ||
done | ||
git push codecommit --tags --force |