Skip to content

Create PR from Dev to Default Branch #3

Create PR from Dev to Default Branch

Create PR from Dev to Default Branch #3

Workflow file for this run

name: Create PR from Dev to Default Branch
on:
workflow_dispatch:
schedule:
- cron: '30 18 * * 6' # Runs every Saturday at midnight IST (adjust as needed)
env:
TARGET_BRANCH=dev

Check failure on line 9 in .github/workflows/pr-creator.yml

View workflow run for this annotation

GitHub Actions / Create PR from Dev to Default Branch

Invalid workflow file

The workflow is not valid. .github/workflows/pr-creator.yml (Line: 9, Col: 3): Unexpected value 'TARGET_BRANCH=dev'
jobs:
create-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create PR
run: |
# Get the default branch name using GitHub API
DEFAULT_BRANCH=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/branches/default" | jq -r .name)
CHANGES_COUNT=$(git rev-list --left-right --count origin/$TARGET_BRANCH...origin/$DEFAULT_BRANCH | awk '{print $1}')
if [ "$CHANGES_COUNT" -eq "0" ]; then
echo "No changes in the '$TARGET_BRANCH' branch. Skipping PR creation."
exit 0
else
# Create a PR from "$TARGET_BRANCH" to the default branch
PR_URL=$(gh pr create --base "$DEFAULT_BRANCH" --head "$TARGET_BRANCH" --title "Auto-generated PR" -t "Auto-generated PR" -b "Auto-generated PR")
echo "Created PR: $PR_URL"
fi
env:
GH_TOKEN: ${{ github.token }}