-
Notifications
You must be signed in to change notification settings - Fork 1
feat: build and push docker image to ghcr workflow #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e233f28
feat: build and push docker image to ghcr workflow
ShehanChamudith 2a9d75b
feat: build workflow before build and push
ShehanChamudith 2bc5d7b
fix: use two seperate scripts for build-go and docker build
ShehanChamudith 27a5a79
fix: separate workflow for release
ShehanChamudith 063d663
fix: remove tag trigger from build workflow
ShehanChamudith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Build and Push Docker Image to GHCR | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*.*.*" | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build-go: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: '1.24' | ||
|
|
||
| - name: Build | ||
| run: go build -v ./... | ||
|
|
||
| - name: Test | ||
| run: go test -v ./... | ||
|
|
||
| build-and-push: | ||
|
||
| needs: build-go | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.ref_type == 'tag' }} | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to GitHub Container Registry (GHCR) | ||
sathirak marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract semver version | ||
| id: extract_version | ||
| run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Build and push Docker image with GHA cache | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: ghcr.io/${{ github.repository_owner }}/pulsebridge:${{ steps.extract_version.outputs.VERSION }} | ||
kasvith marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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