Merge pull request #150 from tinkerbell/dependabot/github_actions/doc… #375
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: For each commit and PR | |
on: | |
push: | |
branches: | |
- "*" | |
tags-ignore: | |
- "v*" | |
pull_request: | |
env: | |
CGO_ENABLED: 0 | |
jobs: | |
verify: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.20" | |
- name: goimports | |
run: go install golang.org/x/tools/cmd/goimports@latest && goimports -d . | (! grep .) | |
- name: make vet | |
run: make vet | |
- name: lint | |
run: make lint | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.20" | |
- name: Unit test | |
run: make test | |
- name: Upload coverage report | |
run: bash <(curl -s https://codecov.io/bash) | |
build: | |
runs-on: ubuntu-latest | |
needs: | |
- verify | |
- test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to quay.io | |
uses: docker/login-action@v3 | |
if: ${{ startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/v') }} | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Docker build meta | |
id: image-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: quay.io/tinkerbell/rufio | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=ref,event=branch,enable=${{ !startsWith(github.ref, 'refs/heads/main') }} | |
type=sha | |
- name: Docker build quay.io/tinkerbell/rufio | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
cache-from: type=registry,ref=quay.io/tinkerbell/rufio:latest | |
tags: ${{ steps.image-meta.outputs.tags }} | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/v') }} |