A implementation of workflows of GitHub Actions to support using gitflow on GitHub with branch protection rules and managing changelog.md.
- Create main, develop branch to repository.
- Add branch protection rules of main, develop branch.
- Add
.github/workflows/gitflow.yml
to repository.name: gitflow on: pull_request: types: - opened - synchronize - reopened - closed branches: - main - develop jobs: gitflow: uses: ab180/gitflow/.github/workflows/gitflow.yml@v2 # with: # MAIN_BRANCH: ... # Default: 'main' # DEVELOP_BRANCH: ... # Default: 'develop' # FEATURE_BRANCHES: ... # Default: 'feature refactor fix change update document test chore dependabot' # RELEASE_BRANCHES: ... # Default: 'release hotfix' # NORELEASE_BRANCHES: ... # Default: 'norelease' # VERSION_EXPRESSION: ... # Default: '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*' # VERSION_HEADER: ... # Default: '## ' # CHANGELOG: ... # Default: 'changelog.md' # secrets: # GITHUB_TOKEN: ... # Default: GitHub Action token # GITHUB_APP_ID: ... # Default: GitHub App ID for fetching GitHub token # GITHUB_APP_PRIVATE_KEY: ... # Default: GitHub App ID for fetching GitHub token # GITHUB_APP_OWNER: ... # Default: GitHub App ID for fetching GitHub token
- Set
Workflow permissions
as checkingRead and write permissions
andAllow GitHub Actions to create and approve pull requests
. - Do not check
Automatically delete head branches
. - Add
gitflow
toRequire status checks to pass before merging
of develop branch. - Add
gitflow
toRequire status checks to pass before merging
of main branch.
%%{ init: { 'gitGraph': { 'showCommitLabel': false,'mainBranchName': 'main' } } }%%
gitGraph
commit tag: "1.0.0"
branch develop
commit
branch feature/name
commit
commit
checkout develop
merge feature/name
branch release/1.1.0
commit
commit
checkout main
merge release/1.1.0 tag: "1.1.0"
checkout develop
merge release/1.1.0
checkout main
branch hotfix/1.1.1
commit
commit
checkout main
merge hotfix/1.1.1 tag: "1.1.1"
checkout develop
merge hotfix/1.1.1
%%{ init: { 'gitGraph': { 'showCommitLabel': false,'mainBranchName': 'develop' } } }%%
gitGraph
commit
branch feature/name
commit
commit
changelog.md
---
+ ## Unreleased
+
+ - feature: ...
+
## 1.0.0
...
- Create branch from develop branch.
- Make branch name as
${FEATURE_TYPE}/name
. - Modify code.
- Add
## Unreleased
to top of changelog.md when do not contains it. - Add description of feature to bottom of
## Unreleased
of changelog.md. - Commit and push.
%%{ init: { 'gitGraph': { 'showCommitLabel': false,'mainBranchName': 'develop' } } }%%
gitGraph
commit
branch feature/name
commit
commit
checkout develop
merge feature/name
changelog.md
---
## Unreleased
- feature: ...
## 1.0.0
...
- Create (
${FEATURE_TYPE}/name
todevelop
) pull request. - GitHub Actions automatically check changelog.md has
## Unreleased
, if possible add## Unreleased
to changelog.md and commit and push, if not close pull request. - GitHub Actions automatically check changelog.md has modification, if not add recommend comment to pull request.
- Merge.
- GitHub Actions automatically delete
${FEATURE_TYPE}/name
branch.
%%{ init: { 'gitGraph': { 'showCommitLabel': false,'mainBranchName': 'develop' } } }%%
gitGraph
commit
branch release/1.1.0
commit
commit
changelog.md
---
+ ## 1.1.0
- ## Unreleased
...
## 1.0.0
...
- Create branch from develop branch.
- Make branch name as
${RELEASE_TYPE}/0.0.0
. - Modify code to change version.
- Modify
## Unreleased
to## 0.0.0
of changelog.md.
%%{ init: { 'gitGraph': { 'showCommitLabel': false,'mainBranchName': 'main' } } }%%
gitGraph
checkout main
commit tag: "1.0.0"
branch develop
commit
branch release/1.1.0
commit
commit
checkout main
merge release/1.1.0 tag: "1.1.0"
checkout develop
merge release/1.1.0
checkout main
branch hotfix/1.1.1
commit
commit
checkout main
merge hotfix/1.1.1 tag: "1.1.1"
checkout develop
merge hotfix/1.1.1
changelog.md
---
## 1.1.0
...
## 1.0.0
...
- Create (
release/0.0.0
orhotfix/0.0.0
tomain
) pull request. - GitHub Actions automatically check branch has valid name, if not close pull request.
- GitHub Actions automatically check changelog.md has
## 0.0.0
and content of## 0.0.0
, if not close pull request. - Merge.
- GitHub Actions automatically create
0.0.0
tag and release. - GitHub Actions automatically append changelog.md's content of
## 0.0.0
to release note. - GitHub Actions automatically append result of GitHub's generate release note feature to release note.
- GitHub Actions automatically merge
release/0.0.0
orhotfix/0.0.0
branch todevelop
branch. - GitHub Actions automatically delete
release/0.0.0
orhotfix/0.0.0
branch.
%%{ init: { 'gitGraph': { 'showCommitLabel': false,'mainBranchName': 'main' } } }%%
gitGraph
checkout main
commit tag: "1.0.0"
branch develop
commit
branch norelease/1.1.0
commit
commit
checkout main
merge norelease/1.1.0 tag: "1.1.0"
checkout develop
merge norelease/1.1.0
- Create (
{NORELEASE_TYPE}/0.0.0
tomain
) pull request. - Merge.
- GitHub Actions automatically merge
{NORELEASE_TYPE}/0.0.0
branch todevelop
branch. - GitHub Actions automatically delete
{NORELEASE_TYPE}/0.0.0
branch.