From 0d9fa1546225fe90cc34a67a94bdd93576048e37 Mon Sep 17 00:00:00 2001 From: Tim Ebert Date: Wed, 1 Nov 2023 18:46:39 +0100 Subject: [PATCH] Add CI workflow --- .github/workflows/controller-sharding.yaml | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/controller-sharding.yaml diff --git a/.github/workflows/controller-sharding.yaml b/.github/workflows/controller-sharding.yaml new file mode 100644 index 00000000..412f11d5 --- /dev/null +++ b/.github/workflows/controller-sharding.yaml @@ -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 '/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