|
| 1 | +# Copyright The Linux Foundation and each contributor to LFX. |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +name: Publish Container Branch |
| 5 | + |
| 6 | +"on": |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + publish: |
| 16 | + name: Publish Container |
| 17 | + if: ${{ github.event.pull_request.head.repo.fork == false }} |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 24 | + - uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 |
| 25 | + with: |
| 26 | + go-version-file: go.mod |
| 27 | + - uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9 |
| 28 | + with: |
| 29 | + version: v0.18.0 |
| 30 | + - name: Prepare container tag |
| 31 | + id: container_tag |
| 32 | + env: |
| 33 | + HEAD_REF: "${{ github.head_ref }}" |
| 34 | + run: | |
| 35 | + container_tag=$(echo "$HEAD_REF" | sed 's/[^_0-9a-zA-Z]/-/g' | cut -c -127) |
| 36 | + echo tag="$container_tag" >> "$GITHUB_OUTPUT" |
| 37 | + - name: Build lfx-v1-sync-helper for PR |
| 38 | + env: |
| 39 | + VERSION: ${{ steps.container_tag.outputs.tag }} |
| 40 | + GIT_COMMIT: ${{ github.sha }} |
| 41 | + run: | |
| 42 | + BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S') |
| 43 | + export BUILD_TIME |
| 44 | + GIT_COMMIT=${GIT_COMMIT:0:7} |
| 45 | + export GIT_COMMIT |
| 46 | + ko build github.com/linuxfoundation/lfx-v1-sync-helper/cmd/lfx-v1-sync-helper \ |
| 47 | + -B \ |
| 48 | + --platform linux/amd64,linux/arm64 \ |
| 49 | + -t ${{ github.sha }} \ |
| 50 | + -t ${{ steps.container_tag.outputs.tag }} \ |
| 51 | + --sbom spdx |
| 52 | + - name: Build dynamodb-stream-consumer for PR |
| 53 | + env: |
| 54 | + VERSION: ${{ steps.container_tag.outputs.tag }} |
| 55 | + GIT_COMMIT: ${{ github.sha }} |
| 56 | + run: | |
| 57 | + BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S') |
| 58 | + export BUILD_TIME |
| 59 | + GIT_COMMIT=${GIT_COMMIT:0:7} |
| 60 | + export GIT_COMMIT |
| 61 | + ko build github.com/linuxfoundation/lfx-v1-sync-helper/cmd/dynamodb-stream-consumer \ |
| 62 | + -B \ |
| 63 | + --platform linux/amd64,linux/arm64 \ |
| 64 | + -t ${{ github.sha }} \ |
| 65 | + -t ${{ steps.container_tag.outputs.tag }} \ |
| 66 | + --sbom spdx |
0 commit comments