name: Sync Back to Dev Branch on: push: branches: - '*' env: EMAIL: ${{ secrets.email }} REPO_BRANCH: ${{ github.ref }} USERNAME: ${{ github.actor }} jobs: sync_back: runs-on: ubuntu-latest steps: - name: Set globals run: | repo=${GITHUB_REPOSITORY#*/} original_repo_issue=${repo::-5} issue_name=${GITHUB_REF#refs/heads/} len_issue=$(( -${#issue_name}-1 )) original_project=${original_repo_issue::${len_issue}} echo "original_project=$original_project" >> $GITHUB_ENV - name: Setup SSH keys run: | mkdir -p ~/.ssh echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 ssh-keyscan github.com >> ~/.ssh/known_hosts - name: Checkout code from mirror uses: actions/checkout@v2 with: ref: ${{ env.REPO_BRANCH }} - name: Checkout dev branch run: | git clone git@github.com:${USERNAME}/${original_project}.git git fetch --unshallow echo ${original_project} cd ${original_project} echo ${GITHUB_REF#refs/heads/} git checkout ${GITHUB_REF#refs/heads/} - name: Merge and Push run: | cd ${original_project} git config pull.rebase false git config --global user.email $EMAIL git config --global user.name $USERNAME git pull ../ ${GITHUB_REF#refs/heads/} git push origin ${GITHUB_REF#refs/heads/}