Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build job #17

Closed
wants to merge 14 commits into from
69 changes: 69 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading