Skip to content

Commit

Permalink
Add CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
timebertt committed Nov 1, 2023
1 parent 2fea8df commit 0d9fa15
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/controller-sharding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: controller-sharding

on:
release:
types:
- published
push:
branches:
- '*'
tags:
- v*
paths-ignore:
- "webhosting-operator/**"
- "**.md"
pull_request:
paths-ignore:
- "webhosting-operator/**"
- "**.md"

jobs:
verify:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Verify
run: make verify

images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- uses: ko-build/setup-ko@v0.6
with:
version: v0.15.0
- name: Prepare image metadata
id: meta
# generate comma-separated tags and labels for image build (similar to docker/metadata-action)
run: |
short_ref=${{ github.ref_name }}
if ${{ github.event_name == 'pull_request' }} ; then
# for PR events, ref_name is '<pr-number>/merge' but tags may not contain /
short_ref=pr-${{ github.event.pull_request.number }}
fi
tags=(
$short_ref
sha-$( echo ${{ github.sha }} | head -c7 )
)
if ${{ github.ref_name == 'master' }} ; then
tags+=( latest )
fi
echo "tags=$(IFS=, ; echo "${tags[*]}")" >> $GITHUB_OUTPUT
labels=(
org.opencontainers.image.created=$( date -u +%Y-%m-%dT%H:%M:%SZ )
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.url=https://github.com/${{ github.repository }}
org.opencontainers.image.version=$short_ref
)
echo "labels=$(IFS=, ; echo "${labels[*]}")" >> $GITHUB_OUTPUT
- name: ko build
run: |
set -ex
ko build --push=${{ github.event_name != 'pull_request' }} --sbom none --base-import-paths --platform linux/amd64,linux/arm64 \
--tags "${{ steps.meta.outputs.tags }}" --image-label "${{ steps.meta.outputs.labels }}" \
./cmd/sharder

0 comments on commit 0d9fa15

Please sign in to comment.