Skip to content

Commit

Permalink
add gha ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoblitt committed Nov 22, 2024
1 parent 02db469 commit a9b9aa0
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 1 deletion.
139 changes: 139 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
name: Build and Publish

"on":
schedule:
- cron: "0 10 * * 1"
push:
branches:
- "**"
tags:
- "v*.*.*"
pull_request:
branches:
- main
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

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

- name: Vet
run: go vet -v ./...

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

hadolint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile

yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run yamllint
uses: bewuethr/yamllint-action@v1

shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master

oci_image:
name: Build OCI Image
needs: build
if: github.repository == 'lsst-dm/s3nd'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- 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.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

gh-release:
name: Create GitHub Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Release
uses: softprops/action-gh-release@v2

go-release:
name: Release Go Binaries
needs: gh-release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "1.22"
asset_name: '${{ github.event.repository.name }}-${{ matrix.goos }}-${{ matrix.goarch }}'
4 changes: 4 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
ignored:
# disable pinning apk package versions
- DL3018
17 changes: 17 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
extends: "default"

rules:
# 80 chars should be enough, but don't fail if a line is longer
line-length: false
indentation:
level: "error"
spaces: 2
indent-sequences: true
# do not obsess over comment formatting
comments-indentation: false
comments:
level: "error"
require-starting-space: false
document-start:
level: "error"
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,6 @@ func main() {
if errors.Is(err, http.ErrServerClosed) {
log.Printf("server closed\n")
} else if err != nil {
log.Fatal("error starting server: %s\n", err)
log.Fatalf("error starting server: %s\n", err)
}
}

0 comments on commit a9b9aa0

Please sign in to comment.