Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 61 additions & 19 deletions .github/workflows/relativity-ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
Expand All @@ -13,24 +9,70 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
build-and-release:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v1

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!
- name: Azure Login
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Runs a set of commands using the runners shell
- name: Run a multi-line script
- name: Get Secrets
uses: Azure/get-keyvault-secrets@v1
with:
keyvault: "ai-services-dev"
secrets: "acrUsername, acrPassword"
id: kv
# On tag, get tag version without v (e.g. v1.0.0 -> 1.0.0, v1.1.1-beta -> 1.1.1-beta)
- name: Get tag version
id: get_version
run: |
if [[ $GITHUB_REF == "refs/tags/v"* ]]; then
echo "Found release tag"
VERSION=${GITHUB_REF/refs\/tags\/v}
else
echo "No release tag found"
VERSION="local-build-only"
fi
echo "Using version: $VERSION"
echo ::set-output name=VERSION::$VERSION
# Build and test binary
- name: Build and Test Binary
env:
CGO_ENABLED: 0
run: |
go mod download
go test -test.timeout 30s
GOOS=linux GOARCH=amd64 go build -o build/linux/amd64/scuttle -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'"
- name: Login to Docker
uses: docker/login-action@v1
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ steps.kv.outputs.acrUsername }}
password: ${{ steps.kv.outputs.acrPassword }}
# Build Docker image
# On tag, push Docker image
- name: Build Docker Image
uses: docker/build-push-action@v2
with:
tags: ${{ secrets.DOCKER_REPOSITORY }}:latest, ${{ secrets.DOCKER_REPOSITORY }}:${{ steps.get_version.outputs.VERSION }}
push: ${{ startsWith(github.ref, 'refs/tags/') }}
build_args: VERSION=${{ steps.get_version.outputs.VERSION }}
# On tag, Pack zip of scuttle for GitHub Release
- name: Pack
run: |
echo Add other actions to build,
echo test, and deploy your project.
mkdir build/artifacts
zip -r -j build/artifacts/scuttle-linux-amd64.zip build/linux/amd64/
if: startsWith(github.ref, 'refs/tags/')
# On tag, Create GitHub Release
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: build/artifacts/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}