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 <[email protected]>
  • Loading branch information
caboteria committed Sep 13, 2023
1 parent 2736057 commit 58cc473
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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 docker-push
- name: Create a new draft release
if: startsWith(github.ref, 'refs/tags/')
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
draft: true
files: |
epic-install.tar.gz
deploy/epic-resource-model.yaml
bin/manager
deploy/manager.service
deploy/manager-restart.service
deploy/manager-restart.path
4 changes: 1 addition & 3 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 Down
10 changes: 9 additions & 1 deletion 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 docker-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,6 +74,10 @@ 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
Expand Down

0 comments on commit 58cc473

Please sign in to comment.