Update ComputeDiscountTest.m #15
This file contains hidden or 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: Auto-create Feature Branches and PRs | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| create_branches_and_prs: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| FEATURE_NAME: testRes | |
| DEV_ASSIGNEE: Vahila | |
| DOC_ASSIGNEE: Vahila | |
| QA_ASSIGNEE: Vahila | |
| RELEASE_ASSIGNEE: Vahila | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up GH CLI | |
| run: | | |
| sudo apt update | |
| sudo apt install -y gh jq | |
| - name: Authenticate GH CLI | |
| run: | | |
| gh auth setup-git | |
| gh auth status | |
| - name: Create branches if not exist | |
| run: | | |
| fname=${FEATURE_NAME} | |
| base=master | |
| echo "Creating branches for feature: $fname" | |
| create_branch() { | |
| branch=$1 | |
| from=$2 | |
| if ! git ls-remote --exit-code origin "refs/heads/$branch" >/dev/null 2>&1; then | |
| echo "Creating branch $branch from $from" | |
| git fetch origin $from | |
| git branch $branch origin/$from | |
| git push origin $branch | |
| else | |
| echo "Branch $branch already exists, skipping." | |
| fi | |
| } | |
| create_branch src/$fname $base | |
| create_branch doc/$fname $base | |
| create_branch test/$fname src/$fname | |
| create_branch feature/$fname $base | |
| - name: Create draft PRs | |
| run: | | |
| fname=${FEATURE_NAME} | |
| echo "Creating draft PRs for $fname" | |
| create_pr() { | |
| head=$1 | |
| base=$2 | |
| title=$3 | |
| body=$3 | |
| assignee=$4 | |
| existing_pr=$(gh pr list --head "$head" --base "$base" --json headRefName,baseRefName --jq '.[]') | |
| if [ -z "$existing_pr" ]; then | |
| echo "Creating PR: $head → $base" | |
| gh pr create \ | |
| --base "$base" \ | |
| --head "$head" \ | |
| --title "$title" \ | |
| --body "$body" \ | |
| --draft \ | |
| ${assignee:+--assignee "$assignee"} | |
| else | |
| echo "PR from $head to $base already exists, skipping." | |
| fi | |
| } | |
| create_pr src/$fname feature/$fname "Source changes for $fname" "$DEV_ASSIGNEE" | |
| create_pr doc/$fname feature/$fname "Docs for $fname" "$DOC_ASSIGNEE" | |
| create_pr test/$fname src/$fname "Tests for $fname" "$QA_ASSIGNEE" | |
| create_pr feature/$fname master "Final changes for $fname" "$RELEASE_ASSIGNEE" |