Synchronize with external repo #2693
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
# repo_sync.yml/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro). | |
# This copyright was auto-generated on Wed, Sep 1, 2021 5:05:36 PM | |
name: Synchronize with external repo | |
on: | |
schedule: | |
- cron: '*/15 * * * *' | |
workflow_dispatch: | |
jobs: | |
repo-sync: | |
if: ${{ github.repository != 'gopro/OpenGoPro' }} | |
name: Mirror external main with internal main | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Public Repoo | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
lfs: true | |
- name: Sync to Internal Repo | |
shell: bash | |
run: | | |
UPSTREAM_REPO="https://github.com/gopro/OpenGoPro" | |
BRANCH_MAPPING="main:main" | |
echo "UPSTREAM_REPO=$UPSTREAM_REPO" | |
echo "BRANCHES=$BRANCH_MAPPING" | |
git config --unset-all http."https://github.com/".extraheader || : | |
echo "Resetting origin to: https://$GITHUB_ACTOR:${{ secrets.PUSH_TO_PROTECTED_BRANCH }}@github.com/$GITHUB_REPOSITORY" | |
git remote set-url origin "https://$GITHUB_ACTOR:${{ secrets.PUSH_TO_PROTECTED_BRANCH }}@github.com/$GITHUB_REPOSITORY" | |
echo "Adding tmp_upstream $UPSTREAM_REPO" | |
git remote add tmp_upstream "$UPSTREAM_REPO" | |
echo "Fetching tmp_upstream" | |
git fetch tmp_upstream --quiet | |
git remote --verbose | |
echo "Pushing changes from tmp_upstream to origin" | |
git push origin "refs/remotes/tmp_upstream/${BRANCH_MAPPING%%:*}:refs/heads/${BRANCH_MAPPING#*:}" --force | |
echo "Removing tmp_upstream" | |
git remote rm tmp_upstream | |
git remote --verbose |