Skip to content

Commit

Permalink
Add docker image build for main
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwenwwer committed Apr 12, 2024
1 parent 3312221 commit d6732e4
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
name: Go
name: Go Build and Test, and Docker Build and Push

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches:
- main
tags:
- 'v*'

jobs:

build:
go-build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21' # or any other Go version

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Build
run: go build ./...

- name: Build
run: go build -v ./...
- name: Test
run: go test ./...

test:
docker-build-and-push:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: go-build-and-test
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21

- name: Test
run: go test -v ./...
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: kerwenwwer/pwrstat-exporter:latest,kerwenwwer/pwrstat-exporter:${{ github.ref_name }}

0 comments on commit d6732e4

Please sign in to comment.