muchisx is making a PR from next into main. #55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: create-pr-next-main | |
run-name: ${{ github.actor }} is making a PR from next into main. | |
on: | |
push: | |
branches: | |
- next | |
jobs: | |
create-pr: | |
name: Create PR | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: next | |
- name: Check if PR already exists | |
id: check-pr-exists | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
prs=$(gh pr list -B main -H next) | |
# Even when there are no PRs, this array always seems to have 1 result | |
echo Size of PRS ARRAY: ${#prs[@]} | |
# Locally, it seems the gh cli says 'no pull requests match your search..' but not here. | |
# The first element exists but is of length 0 | |
echo Length of PRS[0] string: ${#prs[0]} | |
if ((${#prs[@]} > 0 && ${#prs[0]} != 0 )); then | |
echo skipping PR creation | |
echo "skip=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Create PR | |
if: '!steps.check-pr-exists.outputs.skip' | |
run: gh pr create -B main -H next --title 'Merge Next into Main' --body 'Created by Github action' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |