Skip to content

Instantly share code, notes, and snippets.

@zaheeraws
Last active January 30, 2023 12:00
Show Gist options
  • Save zaheeraws/6ebb51d1344e10618557e5bdd1f5e1c8 to your computer and use it in GitHub Desktop.
Save zaheeraws/6ebb51d1344e10618557e5bdd1f5e1c8 to your computer and use it in GitHub Desktop.
# @author Usman Javaid <[email protected]>
# @author Zaheer <[email protected]>
#
# Github Action to push the current repo to another repo.
# Note: PR title should be descriptive as it will be used for commit message
# Create a file .github/workflows/sync-repo.yml
# Steps to setup
# 1. Choose the branch/branches against which to trigger this action.
# 2. Create the following Action variables:
# i. TARGET_BRANCH | Branch to push to the other repository.
# ii. DESTINATION_GITHUB_USERNAME | The username of the github account.
# iii. DESTINATION_REPO_NAME | The name of the repository.
# e.g. in "https://github.com/DESTINATION_GITHUB_USERNAME/DESTINATION_REPO_NAME/"
# iv. USER_NAME | The author username to use while pushing to the other repo.
# v. USER_EMAIL | The author email to use while pushing to the other repo.
# vi. TARGET_BRANCH | The branch to push against.
name: Push to Main Repo
on:
pull_request:
types:
- closed
branches:
- staging
jobs:
push_to_main_repo:
name: Push to Repo
runs-on: ubuntu-latest
container: pandoc/latex
steps:
- uses: actions/checkout@v2
with:
ref: ${{ vars.TARGET_BRANCH }}
- name: Pushes to main repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with:
source-directory: '.'
destination-github-username: '${{ vars.DESTINATION_GITHUB_USERNAME }}'
destination-repository-name: '${{ vars.DESTINATION_REPO_NAME }}'
user-name: ${{ vars.USER_NAME }}
user-email: ${{ vars.USER_EMAIL }}
target-branch: ${{ vars.TARGET_BRANCH }}
commit-message: "${{ github.event.pull_request.title }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment