Skip to content

Repository files navigation

gitflow-workflow-action

A GitHub actions that automate the Gitflow workflow where one has a develop branch for continuous development and a main (production) branch that would automatically deploy to production. In between that, a release branch is created from develop to perform release preparation tasks before being merged to main branch. Occasionally, a hotfix branch is created from main for hot fixes.

Gitflow

Create "Deploy to production" PR

image

We can add a workflow that creates a PR for release. It will create a PR with release note that contains all the new changes in the body. The new branch would be called release/x.y.z.

This basically "freezes" the develop branch for releases. Other PRs can be merged to develop during the release branch lifetime without affecting it.

Create .github/workflows/create-release.yml

on:
workflow_dispatch:
inputs:
version:
type: stringrequired: truedescription: "Version to release"name: Create releasejobs:
pre_release:
runs-on: ubuntu-lateststeps:
- name: gitflow-workflow-action create releaseuses: hoangvvo/gitflow-workflow-actionwith:
develop_branch: "develop"main_branch: "main"version: ${{ inputs.version }}env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Workflows for release lifecycle

Create .github/workflows/post-release.yml

on:
pull_request:
types:
- opened
- closed
- labeledname: Release workflowsjobs:
release_workflow:
runs-on: ubuntu-lateststeps:
- name: gitflow-workflow-action release workflowsuses: hoangvvo/gitflow-workflow-actionwith:
develop_branch: "develop"main_branch: "main"env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This workflow does several things:

  • Autolabel release and hotfix according to the branch name.
  • If the PR is labelled release or hotfix and merged to main, it will create a release, merge back to develop branch, and trigger integrations. This is the process in Gitflow.

Note: It does not handle the deployment process. That is for your team to implement separately.

Integration: Post to Slack

It is often that an anouncement is made to a Slack channel after a release. To do so, specify SLACK_TOKEN env and slack input.

jobs:
release_workflow:
if: github.event.pull_request.merged == trueruns-on: ubuntu-lateststeps:
- name: gitflow-workflow-action release workflowsuses: hoangvvo/gitflow-workflow-actionwith:
develop_branch: "develop"main_branch: "main"slack: > { "channel": "hoang-test", "username_mapping": { "hoangvvo": "U03B3E4UPV3" } }env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages