Skip to content

Merge pull request #183 from retailnext/dependabot/go_modules/google.… #476

Merge pull request #183 from retailnext/dependabot/go_modules/google.…

Merge pull request #183 from retailnext/dependabot/go_modules/google.… #476

Workflow file for this run

---
name: CI
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
env:
REGISTRY: "ghcr.io"
IMAGE_NAME: "${{ github.repository }}"
TEST_IMAGE: "ghcr.io/${{ github.repository }}:test"
permissions:
contents: read
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: '0' # Required for go-header check to know correct mtime of files
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
- name: Set up Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version-file: 'go.mod'
- name: Run pre-commit
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
env:
SKIP: golangci-lint-full
- name: Run golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
- name: Run go tests
run: go test -v ./...
docker:
name: Docker
runs-on: ubuntu-latest
needs:
- 'tests'
permissions:
contents: read
packages: write
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Log in to the Container registry
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build test image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
load: true
tags: ${{ env.TEST_IMAGE }}
cache-from: type=gha
- name: Validate test image
id: validate
run: |
docker run --rm -i ${{ env.TEST_IMAGE }} --help
- name: Extract metadata (tags, labels) for Docker
if: ${{ github.ref == 'refs/heads/main' }}
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
- name: Build and push image
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
cache-from: type=gha
cache-to: type=gha,mode=max
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}