-
-
Notifications
You must be signed in to change notification settings - Fork 2
57 lines (54 loc) · 1.71 KB
/
docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Docker
on:
pull_request:
push:
branches:
- main
tags:
- '*'
env:
CARGO_TERM_COLOR: always
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install docker for macos
if: startsWith(matrix.os, 'macos-')
uses: douglascamata/setup-docker-macos-action@v1-alpha
- name: Databases
run: docker compose up -d
- name: Run tests
run: cargo test --verbose
build-and-releas:
name: build and release docker
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
if: startsWith(github.ref, 'refs/tags/') == false
run: docker build -t geni .
- name: Build Tag
if: startsWith(github.ref, 'refs/tags/')
run: docker build -t ghcr.io/${{ github.repository }}:${{ github.ref_name }} .
- name: Push Tagged Image
if: startsWith(github.ref, 'refs/tags/')
run: docker push ghcr.io/${{ github.repository }}:${{ github.ref_name }}
- name: "Set latest tag"
id: set-latest-tag
run: echo "latest_tag=$(git tag | sort --version-sort | tail -n1)" >> $GITHUB_ENV
- name: Push Latest Image
if: ${{ github.ref_name == env.latest_tag }}
run: |
docker tag ghcr.io/${{ github.repository }}:${{ github.ref_name }} ghcr.io/${{ github.repository }}:latest
docker push ghcr.io/${{ github.repository }}:latest