This repository contains reusable GitHub Actions workflows for Go applications. These workflows standardize the CI/CD process across all Go applications, making maintenance and updates easier.
- Code quality checks (golangci-lint)
- Security scanning (gosec)
- Unit and integration testing
- Semantic versioning and release management
- Docker image building and publishing
- Branch protection enforcement
To use these shared workflows in your Go application, follow these steps:
Create the following files in your repository's .github/workflows directory:
name: "Go Combined Analysis"
on:
pull_request:
branches:
- develop
- main
types:
- opened
- edited
- synchronize
- reopened
permissions:
id-token: write
contents: read
pull-requests: write
actions: read
security-events: write
jobs:
go-analysis:
uses: LerianStudio/github-actions-go-pipeline-template/.github/workflows/analysis.yml@main
secrets:
lerian_studio_push_bot_app_id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
lerian_studio_push_bot_private_key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }}
lerian_ci_cd_user_gpg_key: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY }}
lerian_ci_cd_user_gpg_key_password: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY_PASSWORD }}
lerian_ci_cd_user_name: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
lerian_ci_cd_user_email: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}name: "Release"
on:
push:
branches:
- develop
- main
- hotfix/v*
paths-ignore:
- '.gitignore'
- '**/*.env'
- '*.env'
- '**/*.md'
- '*.md'
- '**/*.txt'
- '*.txt'
tags-ignore:
- '**'
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
publish-release:
uses: LerianStudio/github-actions-go-pipeline-template/.github/workflows/release.yml@main
secrets:
lerian_studio_push_bot_app_id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
lerian_studio_push_bot_private_key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }}
lerian_ci_cd_user_gpg_key: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY }}
lerian_ci_cd_user_gpg_key_password: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY_PASSWORD }}
lerian_ci_cd_user_name: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
lerian_ci_cd_user_email: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}name: "Build Pipeline"
on:
push:
tags:
- '**'
permissions:
id-token: write
contents: read
pull-requests: write
jobs:
build-and-publish:
uses: LerianStudio/github-actions-go-pipeline-template/.github/workflows/build.yml@main
with:
app_name: 'your-app-name'
secrets:
docker_username: ${{ secrets.DOCKER_USERNAME }}
docker_password: ${{ secrets.DOCKER_PASSWORD }}
docker_access_token: ${{ secrets.DOCKER_ACCESS_TOKEN }}name: "Enforce Branch PR's from Develop"
on:
pull_request:
branches:
- main
types:
- opened
- edited
- synchronize
- reopened
jobs:
check-branch:
uses: LerianStudio/github-actions-go-pipeline-template/.github/workflows/check-branch.yml@main
secrets:
lerian_studio_push_bot_app_id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
lerian_studio_push_bot_private_key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }}
lerian_ci_cd_user_gpg_key: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY }}
lerian_ci_cd_user_gpg_key_password: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY_PASSWORD }}
lerian_ci_cd_user_name: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
lerian_ci_cd_user_email: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}Ensure your repository has the necessary secrets configured:
LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_IDLERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEYLERIAN_CI_CD_USER_GPG_KEYLERIAN_CI_CD_USER_GPG_KEY_PASSWORDLERIAN_CI_CD_USER_NAMELERIAN_CI_CD_USER_EMAILDOCKER_USERNAMEDOCKER_PASSWORDDOCKER_ACCESS_TOKEN
To update the shared workflow, follow these steps:
-
Create a new branch from
main:git checkout main git pull git checkout -b feature/your-feature-name
-
Make your changes to the workflow files.
-
Commit and push your changes:
git add . git commit -m "feat: your descriptive commit message" git push origin feature/your-feature-name
-
Create a Pull Request to the
developbranch. -
After testing and approval, the changes will be merged into
develop. -
Once the changes in
develophave been tested and verified, create a Pull Request fromdeveloptomain. -
After approval, the changes will be merged into
mainand available for use in all repositories.
This repository follows a standard Git flow:
mainbranch contains the stable, production-ready code.developbranch is used for integration and testing.- Feature branches (
feature/*) are created frommainfor new features. - Bug fix branches (
fix/*) are created frommainfor bug fixes. - Hotfix branches (
hotfix/v*) are created frommainfor urgent fixes. - All changes must be made through Pull Requests.
- Pull Requests to
maincan only come fromdeveloporhotfix/v*branches.
For questions or issues, please contact the Lerian Studio DevOps team.