Skip to content
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

Docker builds for tags #145

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,52 @@ on:
push:
branches:
- main
tags:
- 'v*'

jobs:
build-and-test:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write # Added permission to push Docker images
packages: write

steps:
- name: Checkout code
uses: actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb # v2
- name: Set up Docker
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3

- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v2
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492 # v2
with:
go-version: '1.23'

- name: Docker
run: make docker-build
- name: Extract Git Tag
if: startsWith(github.ref, 'refs/tags/')
run: echo "GIT_TAG=${{ github.ref_name }}" >> $GITHUB_ENV

- name: Docker Build
run: |
TAG="${GIT_TAG:-latest}"
docker build \
-t ghcr.io/bitbomdev/minefield:latest \
-t ghcr.io/bitbomdev/minefield:"${TAG}" \
.

- name: Log in to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v2
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run build
run: make docker-build

- name: Push Docker images
- name: Push Docker Images
run: |
docker push ghcr.io/bitbomdev/minefield:latest
TAG=${GIT_TAG:-latest}
docker push ghcr.io/bitbomdev/minefield:latest
docker push ghcr.io/bitbomdev/minefield:${TAG}
Loading