Skip to content

Commit

Permalink
feat: update workflows to have rules
Browse files Browse the repository at this point in the history
  • Loading branch information
totonga committed Oct 5, 2024
1 parent 3fad041 commit 0bf962e
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ updates:
- dependency-type: indirect
commit-message:
prefix: "fix: "
target-branch: dev
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
time: "13:00"
commit-message:
prefix: "fix: "
target-branch: dev
4 changes: 2 additions & 2 deletions .github/workflows/schedule-update-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
- uses: actions/checkout@v4.2.0
with:
# [Required] Access token with `workflow` scope.
token: ${{ secrets.PAT }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Run GitHub Actions Version Updater
uses: saadmk11/github-actions-version-updater@v0.8.1
with:
# [Required] Access token with `workflow` scope.
token: ${{ secrets.PAT }}
token: ${{ secrets.GITHUB_TOKEN }}
pull_request_title: "ci: Update GitHub Actions to Latest Version"
13 changes: 13 additions & 0 deletions .github/workflows/semantic-pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,16 @@ jobs:
- uses: amannn/action-semantic-pull-request@v5.5.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
restrict-merge:
name: Restrict PR to main to dev and hotfix/*
runs-on: ubuntu-latest
steps:
- name: Check source branch
if: github.event.pull_request.base.ref == 'main'
run: |
if [[ "${{ github.event.pull_request.head.ref }}" =~ ^(dev|hotfix/.*|release/.*)$ ]]; then
echo "Branch name is valid."
else
echo "Invalid branch name. Only 'dev' or 'hotfix/*' branches can be merged into 'main'."
exit 1
fi
55 changes: 55 additions & 0 deletions docs/branchstrategy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Repository Rules
## Branching strategy

### Main Branches

- **`main`**: This branch contains the stable, production-ready code.
Only thoroughly tested and approved changes are merged here.
- **`dev`**: This is the integration branch for features and fixes.
All new development work is merged here before it goes to `main`.

### Supporting Branches

- **Feature Branches**: Used for developing new features.
These branches are created from `dev` and merged back into `dev` once the feature is complete.
- Naming convention: `feature/feature-name`
- **Bugfix Branches**: Used for fixing bugs. These branches are also created
from `dev` and merged back into `dev` after the fix.
- Naming convention: `bugfix/bug-name`
- **Release Branches**: When preparing for a new release, a release branch is created from `dev`.
This branch is used for final testing and minor bug fixes before merging into `main`.
- Naming convention: `release/x.y.z`
- **Hotfix Branches**: For critical fixes that need to be applied to the production code immediately.
These branches are created from `main` and merged back into both `main` and `dev`.
- Naming convention: `hotfix/x.y.z`

### Workflow Example

#### Feature Development

- Create a feature branch from `dev`:<br/>`git checkout -b feature/new-feature dev`
- Develop the feature and commit changes.
- Merge the feature branch back into `dev`:<br/>`git checkout dev && git merge feature/new-feature`
- Delete the feature branch:<br/>`git branch -d feature/new-feature`

#### Release Preparation

- Create a release branch from `dev`:<br/>`git checkout -b release/1.0.0 dev`
- Perform final testing and bug fixes.
- Merge the release branch into `main`:<br/>`git checkout main && git merge release/1.0.0`
- Tag the release:<br/>`git tag -a v1.0.0 -m "Release 1.0.0"`
- Merge the release branch back into `dev`:<br/>`git checkout dev && git merge release/1.0.0`
- Delete the release branch:<br/>`git branch -d release/1.0.0`

#### Hotfix

- Create a hotfix branch from `main`:<br/>`git checkout -b hotfix/1.0.1 main`
- Apply the hotfix and commit changes.
- Merge the hotfix branch into `main`:<br/>`git checkout main && git merge hotfix/1.0.1`
- Tag the hotfix:<br/>`git tag -a v1.0.1 -m "Hotfix 1.0.1"`
- Merge the hotfix branch into `dev`:<br/>`git checkout dev && git merge hotfix/1.0.1`
- Delete the hotfix branch:<br/>`git branch -d hotfix/1.0.1`

## Merge Requests

Merge request must follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) naming rules.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Welcome to ASAM ODSBox docs's documentation!

overview
odsbox
branchstrategies

Indices and tables
==================
Expand Down

0 comments on commit 0bf962e

Please sign in to comment.