Skip to content

Conversation

@ShehanChamudith
Copy link
Contributor

GitHub Actions Workflow to Build and Push Docker Image to GHCR

Description

This PR introduces a GitHub Actions workflow that automatically builds and pushes a Docker image to GitHub Container Registry (GHCR) on new version tag pushes (v*..). It includes:

  1. Checkout of the repository
  2. Setup of Docker Buildx
  3. Authentication to GHCR
  4. Extraction of the semantic version from the tag
  5. Docker image build and push using GitHub Actions cache for improved performance

This automation ensures consistent, versioned Docker images are published with each release.

JIRA Ticket(s)

JIRA Ticket:

Type of Change

  • New Feature
  • Bug Fix
  • Refactor
  • Documentation Update
  • Other (please specify):

Dependencies

  • Requires:

Breaking Changes

Checklist

  • Locally Tested
  • Ready for QA

@ShehanChamudith ShehanChamudith added the wip Work in progress label Jul 23, 2025
@ShehanChamudith ShehanChamudith requested a review from sathirak July 23, 2025 06:14
- "v*.*.*"

jobs:
build-and-push:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShehanChamudith Make a build workflow that runs before Build and Push to Docker. after the go build is complete, run Build and Push to Docker.

@ShehanChamudith ShehanChamudith requested a review from sathirak July 24, 2025 12:50
workflow_dispatch:

jobs:
build-go:
Copy link
Contributor

@sathirak sathirak Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShehanChamudith can you modify the github actions scripts so that we use two seperate scripts for build-go and docker build (example: build.yml, docker.yml). Docker build needs be be referenced like below from the build.yml and should only be run on tag releases. But build should run on PR to main and Push to main and also on tag releases

   trigger-docker-build:
     needs: [build-go]
     if: github.ref == 'refs/heads/main'
     uses: ./.github/workflows/docker.yml
     secrets: inherit

@ShehanChamudith ShehanChamudith requested a review from sathirak July 28, 2025 10:55
- name: Test
run: go test -v ./...

trigger-binaries:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-binaries

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not build and release for cross platforms with the build.yml

we should maintain two workflows

  1. build.yml for building for anything like main, prs or a tag push
  2. release.yml - triggers only for a tag push

- name: Generate build files
uses: thatisuday/go-cross-build@v1
with:
platforms: 'linux/amd64, darwin/amd64, windows/amd64'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can actually copy that script here and simply run it as i did with the project

platforms: 'linux/amd64, darwin/amd64, windows/amd64'
package: ''
name: 'pulse-bridge'
compress: 'true'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not compress

@kasvith kasvith added this to the v1.0.0 milestone Jul 29, 2025
@ShehanChamudith ShehanChamudith requested a review from sathirak July 29, 2025 11:37
@kasvith kasvith merged commit 0383e26 into main Jul 29, 2025
1 check passed
@kasvith kasvith deleted the feat/build-and-push-ci branch July 29, 2025 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants