Initial commit #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
release: | |
types: [published] | |
jobs: | |
# TODO lint | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22.3' | |
- name: Install dependencies | |
run: go get ./src | |
- name: Build | |
run: go build -v | |
- name: Test with the Go CLI | |
run: go test ./src | |
# Build and push image | |
build-and-publish-image: | |
runs-on: ubuntu-latest | |
needs: | |
# TODO lint dep | |
- build-and-test | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Tag the image | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
bitovi/temporal-cloud-metrics-to-k8s | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref_name == 'main' }} | |
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }} | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
if: github.event_name != 'pull_request' | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- | |
name: Build Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
- | |
name: Push Docker image | |
uses: docker/build-push-action@v4 | |
if: ${{ (github.ref_name == 'main') || (github.event_name == 'release') }} | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
push: true |