Skip to content

Commit

Permalink
feat: add deploy on new version
Browse files Browse the repository at this point in the history
  • Loading branch information
ludusrusso committed Feb 18, 2023
1 parent 5de8d7b commit 26487f3
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/actions/build-docker/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ inputs:
sha:
description: "Git SHA"
required: true
push:
description: "Push Docker"
required: false
default: "false"
outputs:
digest:
description: "Docker Digest"
Expand All @@ -33,14 +37,14 @@ runs:
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern=v{{version}}
type=sha
type=raw,value=${{inputs.branch}}-${{inputs.sha}}-${{ inputs.ts }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
push: ${{ github.ref == 'refs/heads/main' }}
push: ${{ inputs.push }}
network: host
tags: ${{ steps.docker_meta.outputs.tags }}
target: ${{ inputs.docker-target }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- 'main'
Expand Down Expand Up @@ -52,17 +50,20 @@ jobs:
branch: ${{ steps.get_vars.outputs.branch }}
sha: ${{ steps.get_vars.outputs.sha }}
ts: ${{ steps.get_vars.outputs.ts }}
push: ${{ github.ref == 'refs/heads/main' }}
- name: Build Main DB migrations
uses: ./.github/actions/build-docker
with:
docker-target: migrator-db
branch: ${{ steps.get_vars.outputs.branch }}
sha: ${{ steps.get_vars.outputs.sha }}
ts: ${{ steps.get_vars.outputs.ts }}
push: ${{ github.ref == 'refs/heads/main' }}
- name: Build Stats DB migrations
uses: ./.github/actions/build-docker
with:
docker-target: migrator-stats
branch: ${{ steps.get_vars.outputs.branch }}
sha: ${{ steps.get_vars.outputs.sha }}
ts: ${{ steps.get_vars.outputs.ts }}
push: ${{ github.ref == 'refs/heads/main' }}
66 changes: 66 additions & 0 deletions .github/workflows/tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

on:
push:
tags:
- 'v*'

jobs:
test:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
build:
runs-on: ubuntu-20.04
needs: test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Vars
id: get_vars
run: |
echo "ts=$(date +%s)" >> $GITHUB_OUTPUT
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
- name: Build Kannon
uses: ./.github/actions/build-docker
with:
docker-target: kannon
branch: ${{ steps.get_vars.outputs.branch }}
sha: ${{ steps.get_vars.outputs.sha }}
ts: ${{ steps.get_vars.outputs.ts }}
push: true
- name: Build Main DB migrations
uses: ./.github/actions/build-docker
with:
docker-target: migrator-db
branch: ${{ steps.get_vars.outputs.branch }}
sha: ${{ steps.get_vars.outputs.sha }}
ts: ${{ steps.get_vars.outputs.ts }}
push: true
- name: Build Stats DB migrations
uses: ./.github/actions/build-docker
with:
docker-target: migrator-stats
branch: ${{ steps.get_vars.outputs.branch }}
sha: ${{ steps.get_vars.outputs.sha }}
ts: ${{ steps.get_vars.outputs.ts }}
push: true

0 comments on commit 26487f3

Please sign in to comment.