diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..5620bbb --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,69 @@ +name: Build + +on: + push: + branches: + - main + release: + types: + - published + pull_request: + branches: + - main + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Go 1.20 + uses: actions/setup-go@v4 + with: + go-version: '1.20.4' + + - name: Install dependencies + run: | + go install go.opentelemetry.io/collector/cmd/builder@latest + go install github.com/open-telemetry/opentelemetry-collector-contrib/cmd/mdatagen@latest + + - name: Get release tag + if: github.event_name == 'release' + run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Prepare release + run: builder --skip-compilation --config examples/loki/builder-config.yaml + + - name: Build Go binary amd64 + run: cd examples/loki/collector-loki/ && go build -ldflags "-s -w -X main.GitCommit=$GITHUB_SHA -X main.GitRef=$GITHUB_REF -X main.Version=${RELEASE_TAG:-commit-$GITHUB_SHA}" -o castai-collector-loki + env: + GOOS: linux + GOARCH: amd64 + CGO_ENABLED: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + if: ${{ github.event_name == 'pull_request' }} + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push pr + if: ${{ github.event_name == 'pull_request' }} + uses: docker/build-push-action@v2 + with: + context: ./examples/loki/ + file: ./examples/loki/Dockerfile + platforms: linux/arm64,linux/amd64 + push: ${{ github.event_name == 'pull_request' }} + tags: ghcr.io/castai/otelcol-receiver:${{ github.sha }} \ No newline at end of file