Skip to content

Codecommit sync #92

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM amazon/aws-cli:2.0.43

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,23 @@ jobs:
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}

- name: Install AWS
run: |
apt-get update && \
apt-get install -y \
python3 \
python3-pip \
python3-setuptools \
groff \
less \
&& pip3 install --upgrade pip \
&& apt-get clean
pip3 --no-cache-dir install --upgrade awscli

- name: Sync up to CodeCommit
uses: pay-theory/sync-up-to-codecommit-action@v1
with:
repository_name: html-demo
aws_region: us-east-1
run: |
git config --global --add safe.directory /github/workspace
git config --global credential.'https://git-codecommit.*.amazonaws.com'.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
git remote add sync "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/${GITHUB_REPOSITORY}"
git push sync --mirror
13 changes: 13 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -ue

RepositoryName="${GITHUB_REPOSITORY}"
AwsRegion="us-east-1"
CodeCommitUrl="https://git-codecommit.${AwsRegion}.amazonaws.com/v1/repos/${RepositoryName}"

git config --global --add safe.directory /github/workspace
git config --global credential.'https://git-codecommit.*.amazonaws.com'.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
git remote add sync ${CodeCommitUrl}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Codacy found a medium Code Style issue: Double quote to prevent globbing and word splitting.

The issue identified by ShellCheck is related to the use of unquoted variable expansions. When variables are not quoted, they can undergo word splitting and globbing (filename expansion), which can lead to unexpected behavior, especially if the variable contains spaces or special characters.

In the line git remote add sync ${CodeCommitUrl}, the variable ${CodeCommitUrl} should be enclosed in double quotes to prevent such issues.

Here is the code suggestion to fix the issue:

Suggested change
git remote add sync ${CodeCommitUrl}
git remote add sync "${CodeCommitUrl}"

This comment was generated by an experimental AI tool.

git push sync --mirror
Loading