Skip to content

fix: ignore eslint deprecated #23

fix: ignore eslint deprecated

fix: ignore eslint deprecated #23

Workflow file for this run

name: Auto Create PR
on:
push:
branches:
- 'dev-v2*'
- 'feat/**'
- 'fix/**'
- 'refactor/**'
- 'chore/**'
- 'ci-cd/**'
- 'hotfix/**'
- 'release/**'
jobs:
create-pr:
name: Create Pull Request
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for existing PR
id: check_pr
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
branch_name="${GITHUB_REF#refs/heads/}"
existing_pr=$(gh pr list --head "$branch_name" --json number --jq '.[0].number' 2>/dev/null || echo "")
if [ -n "$existing_pr" ]; then
echo "PR already exists: #$existing_pr"
echo "pr_exists=true" >> $GITHUB_OUTPUT
echo "pr_number=$existing_pr" >> $GITHUB_OUTPUT
else
echo "No existing PR found"
echo "pr_exists=false" >> $GITHUB_OUTPUT
fi
- name: Generate PR title and body
if: steps.check_pr.outputs.pr_exists == 'false'
id: pr_content
run: |
branch_name="${GITHUB_REF#refs/heads/}"
prefix=$(echo "$branch_name" | cut -d'/' -f1)
description=$(echo "$branch_name" | cut -d'/' -f2- | sed 's/-/ /g' | sed 's/_/ /g')
case "$prefix" in
feat) title="feat: $description" ;;
fix) title="fix: $description" ;;
refactor) title="refactor: $description" ;;
chore) title="chore: $description" ;;
*) title="$description" ;;
esac
commit_messages=$(git log origin/prod..HEAD --pretty=format:"- %s" 2>/dev/null || echo "- Initial commit")
echo "title=$title" >> $GITHUB_OUTPUT
{
echo "body<<EOF"
echo "## Summary"
echo ""
echo "Auto-generated PR for branch \`$branch_name\`"
echo ""
echo "## Commits"
echo ""
echo "$commit_messages"
echo ""
echo "---"
echo "*This PR was automatically created. Edit the description as needed.*"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.check_pr.outputs.pr_exists == 'false'
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
BRANCH_NAME: ${{ github.ref_name }}
run: |
gh pr create \
--title "${{ steps.pr_content.outputs.title }}" \
--body "${{ steps.pr_content.outputs.body }}" \
--base prod \
--head "$BRANCH_NAME"
- name: Enable auto-merge
if: steps.check_pr.outputs.pr_exists == 'false'
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
sleep 5
branch_name="${GITHUB_REF#refs/heads/}"
pr_number=$(gh pr list --head "$branch_name" --json number --jq '.[0].number')
if [ -n "$pr_number" ]; then
gh pr merge "$pr_number" --auto --squash || echo "Auto-merge not enabled on repo or PR not ready"
fi