Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ghstack_land.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Merge ghstack PRs to main
on:
pull_request:
branches:
- 'gh/*/[0-9]+/base'
- 'kirklandsigntest/*'
jobs:
ghstack_land:
name: ghstack-land
runs-on: ubuntu-22.04
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Try to merge PR to main
run: |
pip install ghstack
pip install pygithub

PR_NUMBER=$(echo "$GITHUB_REF" | grep -oE '[0-9]+')

echo "Checking whether PR $PR_NUMBER is merged"
PR_MERGED=$(python -c "from github import Github; g = Github(); repo = g.get_repo('pytorch/executorch'); pr = repo.get_pull(${PR_NUMBER}); print(1 if pr.merged else 0)")
if [ "$PR_MERGED" = "0" ]; then
echo $"PR $PR_NUMBER is not merged. No op here."
fi
python -c "from github import Auth, Github; g = Github(auth=Auth.Token('${GITHUB_TOKEN}')); repo = g.get_repo('pytorch/executorch'); pr = repo.get_pull(${PR_NUMBER}); pr.create_issue_comment('This PR is not merged into main. Trying to merge it.')"
exit 0

cd .github/workflows/scripts
git config --global user.email "[email protected]"
git config --global user.name "PyTorch Bot"
cat <<EOF > ~/.ghstackrc
[ghstack]
github_url = github.com
github_oauth = $GITHUB_TOKEN
github_username = pytorchbot
remote_name = origin
EOF
# ghstack land "https://github.com/pytorch/executorch/pull/${PR_NUMBER}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REF: ${{ github.ref }}
Loading