Skip to content

Merge pull request #8 from nealajpatel/ghcr #15

Merge pull request #8 from nealajpatel/ghcr

Merge pull request #8 from nealajpatel/ghcr #15

Workflow file for this run

name: "CI"
on:
push:
branches:
- main
pull_request:
jobs:
lint:
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v5
with:
version: latest
test:
needs: lint
strategy:
matrix:
go-version: [1.22.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v4
- name: Test
run: make test
build-multiarch:
needs: test
permissions:
contents: read
pull-requests: read
packages: write
env:
IMAGE_NAME: golang-rest-api-starter
IMAGE_VERSION: 1.0
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
# Checkout buildah action github repository
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.ref == 'refs/head/main' && github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
push: ${{ github.ref == 'refs/head/main' && github.event_name == 'push' && true || false }}
tags: ghcr.io/nealajpatel/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }}