Fix container test #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Golang CI | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
pull_request: | |
jobs: | |
test-unit: | |
name: Run Unit Tests | |
runs-on: ubuntu-22.04 | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20.x' | |
- | |
name: Install dependencies | |
run: go get . | |
- | |
name: Build | |
run: go build -v ./... | |
- | |
name: Test with the Go CLI | |
run: go test ./... | |
format: | |
runs-on: ubuntu-22.04 | |
name: Formate Golang | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20.x' | |
- | |
name: Install dependencies | |
run: go get . | |
- | |
name: Build | |
run: go build -v ./... | |
- | |
name: Run go fmt | |
run: go fmt ./... | |
- | |
name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
commit-message: "🔨 Run `go fmt`" | |
title: 🔨 Reformat Golang Files | |
body: Update Golang files to canonical format using `go fmt ./...` | |
branch: refactor/go-fmt | |
# Delete PR branch if diff is resolved anyhow | |
delete-branch: true | |
labels: | | |
bot | |
kind/cleanup | |
test-image: | |
name: Build and Test Docker Image | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Build and export to Docker | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
load: true | |
tags: | | |
image:testing | |
- | |
name: Test image functionality | |
uses: plexsystems/container-structure-test-action@cc689017bbb16a3c98e6e87b0e07f92ad35a9df1 | |
with: | |
image: image:testing | |
config: container-structure-test.yaml | |
build: | |
name: Build and Push Docker Image | |
runs-on: ubuntu-22.04 | |
needs: [ test-unit, test-image ] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Prepare Docker metadata | |
id: image-metadata | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
flavor: | | |
latest=true | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }} | |
labels: | | |
org.opencontainers.image.vendor=${{ github.repository_owner }} | |
org.label-schema.schema-version=1.0 | |
org.label-schema.vcs-url=https://github.com/${{ github.repository }}.git | |
org.label-schema.docker.cmd.help=docker run --rm -it $CONTAINER help | |
- | |
name: Login to GitHub Container Registry | |
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: | |
context: . | |
push: true | |
tags: ${{ steps.image-metadata.outputs.tags }} | |
labels: ${{ steps.image-metadata.outputs.labels }} |