Skip to content

Update .random

Update .random #10

name: Pull Request on Push to branch
on:
push:
branches-ignore:
- main
- dev
jobs:
create-pull-request:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: dev
- name: Create PR
run: |
echo "Get the list of PR for that branch that are open"
gh pr list -H $BRANCH_TO_MERGE --json number -s "open" > pr_list.json
pr_count=$(jq length pr_list.json)
echo "Checking if there are any PR already"
if [[ pr_count -gt 0 ]]; then
echo "Indeed there is at least one PR for this branch"
else
echo "There is no PR for this branch so we create one"
gh pr create -B $BASE_BRANCH -H $BRANCH_TO_MERGE --title "$PR_TITLE" --body "$PR_BODY"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TITLE: "Autocreated PR: ${{ github.ref_name}}"
PR_BODY: "Created by Github action"
BASE_BRANCH: "dev"
BRANCH_TO_MERGE: ${{ github.ref}}