Skip to content

Commit

Permalink
ci(actions): added github actions to automate pr creation
Browse files Browse the repository at this point in the history
  • Loading branch information
nikensss committed Mar 30, 2024
1 parent 4664422 commit 90e2041
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/create-pr-to-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: create pull request to dev

on:
push:
branches-ignore:
- main
- dev
- master

jobs:
createDraftPR:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Execute bash script
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x ./scripts/create-pr-to-dev
./scripts/create-pr-to-dev
20 changes: 20 additions & 0 deletions .github/workflows/create-pr-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: create pull request to main

on:
push:
branches:
- dev

jobs:
createDraftPR:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Execute bash script
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x ./scripts/create-pr-to-main
./scripts/create-pr-to-main
11 changes: 11 additions & 0 deletions scripts/create-pr-to-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

TICKET=$(git branch --show-current | sed 's/^\(.*\)--\(.*\)$/\1/' | tr '[:lower:]' '[:upper:]')
DESC=$(git branch --show-current | sed 's/^.*--\(.*\)$/\1/;s/-/ /')

if [[ $(gh pr list --json 'headRefName,baseRefName' | jq "[ .[] | select(.baseRefName == \"dev\" and .headRefName == \"$(git branch --show-current)\") ] | length") -gt 0 ]]; then
echo "WARN: PR already exists, skipping."
exit 0
fi

gh pr create -B dev -H $(git branch --show-current) -t "$TICKET - $DESC" -b "$DESC"
10 changes: 10 additions & 0 deletions scripts/create-pr-to-main
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

TICKET=$(git branch --show-current | sed 's/^\(.*\)--\(.*\)$/\1/' | tr '[:lower:]' '[:upper:]')
DESC=$(git branch --show-current | sed 's/^.*--\(.*\)$/\1/;s/-/ /')

if [[ $(gh pr list --json 'headRefName,baseRefName' | jq "[ .[] | select(.headRefName == \"dev\" and .baseRefName == \"main\") ] | length") -gt 0 ]]; then
exit 0
fi

gh pr create -B main -H dev -t "Prod release" -b "This PR has been created automatically by a GitHub Action."

0 comments on commit 90e2041

Please sign in to comment.