Skip to content

Instantly share code, notes, and snippets.

@uladz-zubrycki
Created November 16, 2021 09:05
Show Gist options
  • Select an option

  • Save uladz-zubrycki/8b955b4b6fd66e0eeb5135878c7b2e42 to your computer and use it in GitHub Desktop.

Select an option

Save uladz-zubrycki/8b955b4b6fd66e0eeb5135878c7b2e42 to your computer and use it in GitHub Desktop.
Github Action: Clone PR to another repository
# Github action to clone PR to another repository.
name: clone-pr
on:
pull_request:
types: [ opened ]
branches: [ main ]
jobs:
clone:
runs-on: ubuntu-latest
steps:
# Checkout PR branch, push to the remote repo and create PR
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- run: |
git checkout ${{ github.head_ref }}
git config --unset-all http.https://github.com/.extraheader
git push https://v-zubritsky:${{ secrets.API_TOKEN }}@github.com/v-zubritsky/tmp-clone.git
echo '${{ secrets.API_TOKEN }}' | gh auth login --with-token
gh pr create --base main --title '${{ github.event.pull_request.title }}' --body '${{ github.event.pull_request.body }}' --head '${{ github.head_ref }}' --repo 'v-zubritsky/tmp-clone'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment