CAPT Playground #778
Workflow file for this run
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: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
env: | |
CGO_ENABLED: 0 | |
GO_VERSION: '1.21' | |
REGISTRY: ghcr.io | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
validate: | |
name: "Validate ${{ matrix.target }}" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
target: ["verify", "lint", "test"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: "${{ env.GO_VERSION }}" | |
cache: true | |
- uses: actions/cache@v4 | |
with: | |
path: hack/tools/bin | |
key: ${{ runner.os }}-tools-bin-${{ matrix.target }}-${{ hashFiles('Makefile') }} | |
restore-keys: | | |
${{ runner.os }}-tools-bin-${{ matrix.target }}- | |
${{ runner.os }}-tools-bin- | |
- uses: actions/cache@v4 | |
if: ${{ matrix.target == 'test' }} | |
with: | |
path: /tmp/kubebuilder-tools-*.tar.gz | |
key: ${{ runner.os }}-tmp-${{ matrix.target }}-${{ hashFiles('scripts/fetch_ext_bins.sh') }} | |
restore-keys: | | |
${{ runner.os }}-tmp-${{ matrix.target }}- | |
${{ runner.os }}-tmp- | |
- name: ${{ matrix.target }} | |
run: make ${{ matrix.target }} | |
codespell: | |
name: Codespell | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Codespell | |
uses: codespell-project/[email protected] | |
with: | |
check_filenames: true | |
check_hidden: true | |
skip: "./.git,./go.mod,./go.sum" | |
ignore_words_list: ro | |
build-and-push-image: | |
name: Build and push manager image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to ghcr.io | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=sha | |
type=raw,value=latest | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: ${{ github.event_name != 'pull_request' && 'linux/amd64,linux/arm64' || 'linux/amd64' }} |