Create some StepAction to fetch and upload caches… #29
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
on: | |
pull_request: | |
branches: [ main ] | |
push: | |
branches: [ main ] | |
schedule: | |
- cron: '0 0 * * *' | |
name: build-test-publish | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Set up Go | |
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version: "1.21" | |
- run: go env | |
- name: go build | |
run: go build -v ./... | |
- name: go unit test | |
run: go test -v ./... | |
e2e: | |
name: e2e tests | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
steps: | |
- uses: ko-build/[email protected] | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- uses: chainguard-dev/actions/setup-kind@main | |
with: | |
k8s-version: v1.23.x | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version: "1.21.x" | |
- uses: openshift-pipelines/setup-tektoncd@v1 | |
with: | |
pipeline: v0.56.x | |
feature-flags: '{"enable-step-actions": "true"}' | |
- name: tests | |
run: | | |
REGISTRY=registry.registry.svc.cluster.local:32222 | |
KO_DOCKER_REPO=${REGISTRY}/cache ko pulbish --base-import-paths --tags=latest ./cmd/cache | |
sed "s/image:.*/image:${REGISTRY}\/cache:latest/g" tekton/cache-fetch.yaml | kubectl apply -f - | |
sed "s/image:.*/image:${REGISTRY}\/cache:latest/g" tekton/cache-upload.yaml | kubectl apply -f - | |
kubectl apply -f tests/ | |
tkn task start cache-fetch-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog | |
tkn task start cache-upload-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog | |
tkn task start cache-fetch-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog | |
tkn taskrun list | |
# FIXME: fail if something failed | |
publish: | |
name: publish latest | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version: "1.21" | |
- id: meta | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # 5.5.1 | |
with: | |
images: ghcr.io/${{ github.repository }}/cache | |
flavor: | | |
latest=${{ github.event_name != 'pull_request' }} | |
- uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # 3.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: ko-build/[email protected] | |
- run: | | |
ko publish --push=${{ github.event_name != 'pull_request' }} --base-import-paths ./cmd/cache |