Skip to content

Instantly share code, notes, and snippets.

@vtenq
Last active October 29, 2022 16:13
Show Gist options
  • Save vtenq/50cd012f247630bb4d3a1041dc82ba30 to your computer and use it in GitHub Desktop.
Save vtenq/50cd012f247630bb4d3a1041dc82ba30 to your computer and use it in GitHub Desktop.

Simplified Git flow with GitHub Actions

Main concepts:

  • remove development branch
  • use master as the only and main branch
  • squash feature branches into master directly

CI

  • run lint test build jobs before merging into master
  • do not run auto release on push to master
  • add workflow with manual trigger to run release job

Release workflow with manual trigger example:

name: Release
on:
  workflow_dispatch:
    inputs:
      name:
        description: 'Release name'
        required: false

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Install dependencies
      run: yarn install --pure-lockfile

    - name: Check build
      run: yarn build

    - name: Semantic Release
      uses: vtenq/semantic-release-action@master
      id: semantic
      with:
        extra_plugins: |
          @semantic-release/changelog
          @semantic-release/git
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This will add new Release workflow that can be manually triggered in Actions panel when you feel that master branch is ready for release. It will tag latest commit with new version so you will always know the commit that was released.

image

CD

  • on push to master deploy automatically to staging
  • trigger manually deploy to production after release was done
  • OR set up deploy in release workflow
  • OR set up deploy on new git tag created
  • OR improvise

References:

GitHub Actions workflow dispatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment