Home > Enterprise >  Github Actions to mirror and sync with AWS codecommit
Github Actions to mirror and sync with AWS codecommit

Time:07-12

I am planning to Synchronize a repo in GitHub and to AWS codecommit. All the present code and future PR's merging to main, dev, and preprod should be in the AWS codecommit. I am referring to GitHub Actions and I see three different wiki/documentation. I am not sure which one to follow?

1.https://github.com/marketplace/actions/github-to-aws-codecommit-sync

2.https://github.com/marketplace/actions/mirroring-repository

3.https://github.com/marketplace/actions/automatic-repository-mirror

CodePudding user response:

The first one (actions/github-to-aws-codecommit-sync) should be enough.

Its script entrypoint.sh does a:

git config --global credential.'https://git-codecommit.*.amazonaws.com'.helper '!aws codecommit credential-helper $@'
git remote add sync ${CodeCommitUrl}
git push sync --mirror

That should pull all branches, including PR branches (in refs/pull/ namespace)

That action should be called on merged PR:

name: OnMergedPR
on:
  push:
    branches:
      - "**"
      - "!main"

  pull_request:
    branches:
      - main
    types: [opened, synchronize, closed]

  workflow_dispatch: 

jobs:   
  build:
    if: (!(github.event.action == 'closed' && github.event.pull_request.merged != true))

...
  • Related