-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec57626
commit f8e99db
Showing
2 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '.github/**' | ||
- '.gitignore' | ||
branches: | ||
- main | ||
tags: | ||
- 'v*.*.*' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup golang | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22 | ||
- name: Install dependencies | ||
run: make deps | ||
- name: Unit Test | ||
run: make test | ||
|
||
- name: Convert coverage report to table | ||
run: go tool cover -func=coverage.out | tail -n +2 | awk '{print "|",$1,"|",$3,"|"}' > coverage_table.md | ||
|
||
- name: Comment on PR with coverage table | ||
if: github.event_name == 'pull_request' | ||
working-directory: cmd/tools/pr | ||
run: go mod tidy && go run main.go | ||
continue-on-error: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REPO_NAME: ${{ github.repository }} | ||
PR_NUMBER: ${{ github.event.number }} | ||
COVERAGE_FILE: ../../../coverage_table.md | ||
- name: Build | ||
run: make build | ||
- name: Vendor | ||
run: go mod vendor | ||
|
||
# Login against a Docker registry except on PR | ||
# https://github.com/docker/login-action | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
if: github.event_name != 'pull_request' | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
# https://github.com/docker/metadata-action | ||
- name: Extract Docker metadata | ||
id: meta | ||
if: github.event_name != 'pull_request' | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}' | ||
flavor: | | ||
latest=auto | ||
tags: | | ||
type=schedule | ||
type=ref,event=tag | ||
type=sha,prefix=,format=long,enable=true,priority=100 | ||
# Build and push Docker image with Buildx (don't push on PR) | ||
# https://github.com/docker/build-push-action | ||
- name: Build and push Docker image | ||
if: github.event_name != 'pull_request' | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64 |
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