Skip to content

Test Script to ghstack land #2

Test Script to ghstack land

Test Script to ghstack land #2

Workflow file for this run

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
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- 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.GARDENER_PAT }}
GITHUB_REF: ${{ github.ref }}