Skip to content

CI 🏗

CI 🏗 #123

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
GO_VERSION: "1.20"
jobs:
lint_test:
name: Lint & test code.
runs-on: ubuntu-latest
env:
GOLANGCILINT_VERSION: "v1.52"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GOLANGCILINT_VERSION }}
- name: Vet
run: go vet ./...
- name: Test
run: go test -race -cover ./...
build:
name: Build binary & container image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Build binary
run: |
mkdir build
env CGO_ENABLED=0 go build -o build ./...
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: bifrost
path: |
build/*
docs/issuer/openapi.yaml
- if: github.ref == 'refs/heads/main'
run: echo "LATEST_TAG=latest" >>"$GITHUB_ENV"
- if: github.event_name == 'pull_request'
run: echo "PR_TAG=pr-${{ github.event.pull_request.number }}" >>"$GITHUB_ENV"
- name: Build bifrost container image
uses: redhat-actions/buildah-build@v2
id: build_bifrost
with:
base-image: gcr.io/distroless/base-debian11
content: |
build/*
entrypoint: /bf
image: ${{ github.repository }}
tags: >
${{ env.LATEST_TAG }}
${{ env.PR_TAG }}
${{ github.sha }}
${{ github.event.release.tag_name }}
- name: Push bifrost image to ghcr.io
uses: redhat-actions/push-to-registry@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image: ${{ steps.build_bifrost.outputs.image }}
tags: ${{ steps.build_bifrost.outputs.tags }}
- name: Update Github release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
append_body: true
generate_release_notes: true
files: |
build/*
docs/issuer/openapi.yml
ca_image:
name: Deploy bifrost-ca image
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build bifrost-ca image
uses: redhat-actions/buildah-build@v2
id: build_ca
with:
build-args: GO_VERSION=${{ env.GO_VERSION }}
image: bifrost-ca
tags: >
latest
${{ github.sha }}
${{ github.event.release.tag_name }}
containerfiles: ca.Containerfile
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.QW_AWS_ACCESS_KEY_ID_PROD }}
aws-secret-access-key: ${{ secrets.QW_AWS_SECRET_ACCESS_KEY_PROD }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Push bifrost-ca to Amazon ECR
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ steps.login-ecr.outputs.registry }}
image: ${{ steps.build_ca.outputs.image }}
tags: ${{ steps.build_ca.outputs.tags }}