Skip to content

Commit

Permalink
Add a GitHub action for continuous integration
Browse files Browse the repository at this point in the history
Signed-off-by: Toby Cabot <toby@acnodal.io>
  • Loading branch information
caboteria committed Sep 15, 2023
1 parent 2736057 commit ca93e91
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 9 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
with: {submodules: recursive}

- uses: actions/setup-go@v4
with: {go-version: '=1.19.8'}

- name: Decide what we're going to call this
run: |
TAG_SPECIFIC=${{ github.ref_name }}
# if we're building from a branch (i.e., not a tag) then add
# the short sha so we can have more than one build per branch
if [[ ${{ github.ref }} != refs/tags/* ]]; then
TAG_SPECIFIC=${TAG_SPECIFIC}-$(git rev-parse --short HEAD)
fi
echo $TAG_SPECIFIC
echo "TAG_SPECIFIC=$TAG_SPECIFIC" >> $GITHUB_ENV
- name: Make
run: |
make SUFFIX=${TAG_SPECIFIC} all
- name: Push
if: startsWith(github.ref, 'refs/tags/')
run: |
docker login -u epic-gateway+github_actions -p ${{ secrets.QUAY_EPIC_GATEWAY }} quay.io
make SUFFIX=${TAG_SPECIFIC} go-push image-push
- name: Create a new pre-release
if: startsWith(github.ref, 'refs/tags/')
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
files: |
epic-install.tar.gz
deploy/epic-resource-model.yaml
bin/manager
deploy/manager.service
deploy/manager-restart.service
deploy/manager-restart.path
6 changes: 2 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ manifest:
- apt-get install -y gettext-base

script:
- make SUFFIX=${TAG_SPECIFIC} all
- tar czf epic-install.tar.gz config deploy
- make SUFFIX=${TAG_SPECIFIC} all go-push
- 'curl --silent --show-error --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file epic-install.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/manifest-package/${TAG_SPECIFIC}/epic-install.tar.gz"'
- 'curl --silent --show-error --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file deploy/epic-resource-model.yaml "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/manifest-package/${TAG_SPECIFIC}/epic-resource-model.yaml"'
- 'curl --silent --show-error --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/manager "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/manifest-package/${TAG_SPECIFIC}/manager"'
- 'curl --silent --show-error --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file deploy/manager.service "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/manifest-package/${TAG_SPECIFIC}/manager.service"'
- 'curl --silent --show-error --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file deploy/manager-restart.service "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/manifest-package/${TAG_SPECIFIC}/manager-restart.service"'
- 'curl --silent --show-error --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file deploy/manager-restart.path "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/manifest-package/${TAG_SPECIFIC}/manager-restart.path"'
# FIXME: "go list" this module to add it to the checksum db

docker:
image: docker:20.10.5
Expand All @@ -39,4 +37,4 @@ docker:
- docker login -u epic-gateway+gitlab_ci -p $QUAY_EPIC_GATEWAY quay.io

script:
- make SUFFIX=${TAG_SPECIFIC} docker-build docker-push
- make SUFFIX=${TAG_SPECIFIC} image-build image-push
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

all: manifests manager
all: tar image-build

# Build release tarball
tar: manifests manager
tar czf epic-install.tar.gz config deploy

# Run tests
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
Expand Down Expand Up @@ -70,17 +74,21 @@ fmt:
vet:
go vet ./...

.PHONY: go-push
go-push:
GOPROXY=proxy.golang.org go list -m epic-gateway.org/${PREFIX}@${SUFFIX}

# Generate code
.PHONY: generate
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# Build the docker image
docker-build:
# Build the container image
image-build:
docker build . -t ${IMG}

# Push the docker image
docker-push:
# Push the container image
image-push:
docker push ${IMG}

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
Expand Down

0 comments on commit ca93e91

Please sign in to comment.