Skip to content

Build and push container images on main: (#496) #1116

Build and push container images on main: (#496)

Build and push container images on main: (#496) #1116

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
env:
CGO_ENABLED: 0
GO_VERSION: '1.25'
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
validate:
name: "Validate ${{ matrix.target }}"
runs-on: ubuntu-latest
strategy:
matrix:
target: ["verify", "lint", "test"]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- uses: actions/cache@v4
with:
path: bin
key: ${{ runner.os }}-tools-bin-${{ matrix.target }}-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-tools-bin-${{ matrix.target }}-
${{ runner.os }}-tools-bin-
- name: ${{ matrix.target }}
run: make ${{ matrix.target }}
codespell:
name: Codespell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Codespell
uses: codespell-project/actions-codespell@v2.1
with:
check_filenames: true
check_hidden: true
skip: "./.git,./go.mod,./go.sum,.goreleaser.yaml"
ignore_words_list: ro,NotIn
build:
name: Build binaries and container images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Build
run: make build-image
build-push-image:
name: Build and push image
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- validate
- codespell
- build
steps:
- name: Checkout code
uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
run: make build-image-push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_RELEASE: false