Files
OpenBB/.github/workflows/branch-name-check.yml
Luqman 7d668b10c8 Final Implementation of Changelog V2 (#6050)
* Updated the release drafter to process the released changelog for OpenBB Platform

* Update release drafter configuration

* Add OpenBB Documentation Changes and Create Release

* Update process_changelog.py path in draft-release.yml

* Update release-drafter version and save changelog

* Copy changelog with python

* Update draft-release.yml to save Changelog

* Update draft-release.yml

* Encode and save Changelog to Base64

* Update Changelog saving method

* Update Changelog format

* Update CHANGELOG.md with release notes

* Fix draft release workflow

* Add cat command to print CHANGELOG.md

* Add platform-drafter.yml and update release-drafter.yml and draft-release.yml

* Commented out config-name in release-drafter step

* Update branch name validation and process_changelog.py

* Refactor process_changelog.py to improve readability and maintainability

* Refactor process_changelog.py to handle file I/O errors and remove duplicate PR entries

---------

Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
2024-02-08 09:38:06 +00:00

54 lines
2.0 KiB
YAML
Vendored

name: Branch Name Check
on:
pull_request:
branches:
- develop
- main
types: [opened, synchronize, edited]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-branch-name:
runs-on: ubuntu-latest
outputs:
source-branch: ${{ steps.branch-name-check.outputs.source-branch }}
target-branch: ${{ steps.branch-name-check.outputs.target-branch }}
steps:
- name: Extract branch names
id: branch-name-check
run: |
source_branch=$(jq -r .pull_request.head.ref "$GITHUB_EVENT_PATH")
target_branch=$(jq -r .pull_request.base.ref "$GITHUB_EVENT_PATH")
echo "Source-branch=$source_branch" >> $GITHUB_OUTPUT
echo "target-branch=$target_branch" >> $GITHUB_OUTPUT
- name: Show Output result for source-branch and target-branch
run: |
echo "source-branch=${{ steps.branch-name-check.outputs.source-branch }}"
echo "target-branch=${{ steps.branch-name-check.outputs.target-branch }}"
- name: Check branch name for develop PRs
if: ${{ steps.branch-name-check.outputs.target-branch == 'develop' }}
run: |
if [[ "${{ steps.branch-name-check.outputs.source-branch }}" =~ ^(main|feature/.*|docs/.*|hotfix/.*|bugfix/.*|release/[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?)$ ]]; then
echo "Branch name is valid"
else
echo "Invalid branch name. Branches must follow the GitFlow naming convention to be allowed to merge into the develop branch."
exit 1
fi
- name: Check branch name for main PRs
if: ${{ steps.branch-name-check.outputs.target-branch == 'main' }}
run: |
if [[ "${{ steps.branch-name-check.outputs.source-branch }}" =~ ^(hotfix/.*|release/[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?)$ ]]; then
echo "PR is from a hotfix or release branch and targets the main branch"
else
echo "PR is not from a hotfix or release branch. Pull requests must be from a hotfix or release branch and target the main branch"
exit 1
fi