83 lines
2.7 KiB
YAML
83 lines
2.7 KiB
YAML
env:
|
|
ARTIFACT_NAME: bk-infra9-metal-bridge
|
|
BIN_NAME: infra9-metal-bridge
|
|
DEPLOYMENT_REPO: k8s-infra9-metal-bridge
|
|
GOPRIVATE: go.equinixmetal.net/*
|
|
IMAGE_TAG: ${BUILDKITE_BUILD_NUMBER}-${BUILDKITE_COMMIT:0:8}
|
|
QUAY_REPO: quay.io/equinixmetal/infra9-metal-bridge
|
|
|
|
steps:
|
|
- label: ":golangci-lint: lint"
|
|
key: "lint"
|
|
command: |
|
|
make lint
|
|
plugins:
|
|
- docker#v5.3.0:
|
|
image: "golangci/golangci-lint:v1.51.2"
|
|
volumes:
|
|
- "/var/lib/buildkite-agent/.gitconfig/:/root/.gitconfig/"
|
|
|
|
- label: ":test_tube: test"
|
|
key: "test"
|
|
command: |
|
|
make test
|
|
plugins:
|
|
- docker#v5.3.0:
|
|
image: "golang:1.20"
|
|
volumes:
|
|
- "/var/lib/buildkite-agent/.gitconfig/:/root/.gitconfig/"
|
|
|
|
- label: ":golang: build"
|
|
key: "gobuild"
|
|
commands: |
|
|
CGO_ENABLED=0 go build -o ${ARTIFACT_NAME} -buildvcs=false ./main.go
|
|
artifact_paths: "${ARTIFACT_NAME}"
|
|
plugins:
|
|
- docker#v5.6.0:
|
|
image: "golang:1.20"
|
|
volumes:
|
|
- "/var/lib/buildkite-agent/.gitconfig:/root/.gitconfig"
|
|
|
|
- label: ":whale: docker build"
|
|
key: "build"
|
|
depends_on: ["lint", "test", "gobuild"]
|
|
commands: |
|
|
#!/bin/bash
|
|
echo --- Retrieve artifacts
|
|
buildkite-agent artifact download "${ARTIFACT_NAME}" .
|
|
mv "${ARTIFACT_NAME}" "${BIN_NAME}"
|
|
|
|
# make sure it is executable
|
|
chmod +x ${BIN_NAME}
|
|
|
|
echo --- Build Docker Image
|
|
docker build . -t "$QUAY_REPO:$IMAGE_TAG"
|
|
|
|
echo --- Push Docker Image
|
|
docker push "$QUAY_REPO:$IMAGE_TAG"
|
|
|
|
buildkite-agent annotate --style "success" "Image pushed to quay [$QUAY_REPO:$IMAGE_TAG](https://$QUAY_REPO:$IMAGE_TAG)"
|
|
|
|
# For main commits, pull-requests will be created to bump the image in the deployment manifest
|
|
- label: "Bump image tag for main branch builds"
|
|
depends_on:
|
|
- "build"
|
|
if: build.branch == 'main'
|
|
plugins:
|
|
- first-aml/git-clone:
|
|
repository: git@github.com:equinixmetal/$DEPLOYMENT_REPO.git
|
|
- ssh://git@github.com/equinixmetal/ssm-buildkite-plugin#v1.0.3:
|
|
parameters:
|
|
GITHUB_TOKEN: /buildkite/github/personal-access-token/v1
|
|
- ssh://git@github.com/packethost/yaml-update-buildkite-plugin#v1.0.1:
|
|
dir: $DEPLOYMENT_REPO
|
|
file: values.yaml
|
|
values:
|
|
- .bridge.image.tag=$IMAGE_TAG
|
|
- ssh://git@github.com/equinixmetal/github-pr-template-buildkite-plugin#v0.2.0: {}
|
|
# Create Pull Request to main using commit from previous step
|
|
- envato/github-pull-request#v0.4.0:
|
|
title: '[buildkite] bump image tag to $IMAGE_TAG'
|
|
head: buildkite-yaml-update-$BUILDKITE_BUILD_NUMBER
|
|
base: main
|