-
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
Changes from 3 commits
e233f28
2a9d75b
2bc5d7b
27a5a79
063d663
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: Generate release-artifacts | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| generate: | ||
| name: Generate cross-platform builds | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout the repository | ||
| uses: actions/checkout@v2 | ||
| - name: Generate build files | ||
| uses: thatisuday/go-cross-build@v1 | ||
| with: | ||
| platforms: 'linux/amd64, darwin/amd64, windows/amd64' | ||
| package: '' | ||
| name: 'pulse-bridge' | ||
| compress: 'true' | ||
|
||
| dest: 'dist' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,23 +3,37 @@ name: Build | |
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| tags: | ||
| - "v*.*.*" | ||
| pull_request: | ||
| branches: [ "main","*" ] | ||
|
|
||
| jobs: | ||
|
|
||
| build: | ||
| build-go: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: '1.24' | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: '1.24' | ||
|
|
||
| - name: Build | ||
| run: go build -v ./... | ||
| - name: Build | ||
| run: go build -v ./... | ||
|
|
||
| - name: Test | ||
| run: go test -v ./... | ||
| - name: Test | ||
| run: go test -v ./... | ||
|
|
||
| trigger-binaries: | ||
|
||
| needs: build-go | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| uses: ./.github/workflows/binaries.yml | ||
| secrets: inherit | ||
|
|
||
| trigger-docker-build: | ||
| needs: build-go | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| uses: ./.github/workflows/docker.yml | ||
| secrets: inherit | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Build and Push Docker Image to GHCR | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| build-and-push: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| 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) | ||
| 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 }}/pulse-bridge:${{ steps.extract_version.outputs.VERSION }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max |
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.
shall we include following platforms? https://github.com/kasvith/hackerrank-dl/blob/6b61b6d2d7a8cc8e562360111f9a7fc9cb41023d/build/build.sh#L38
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.
you can actually copy that script here and simply run it as i did with the project