-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (81 loc) · 2.48 KB
/
ci.yml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: CICD
on:
workflow_dispatch:
push:
branches:
- "master"
tags:
- "v*"
pull_request:
branches:
- "master"
concurrency:
group: cicd-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io/${{ github.repository_owner }}
jobs:
test:
name: Test
runs-on: ubuntu-latest
concurrency:
group: cicd-test-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: coursier/cache-action@v6
- uses: sbt/setup-sbt@v1
- uses: VirtusLab/scala-cli-setup@v1
with:
jvm: 21
- run: scala-cli fmt --check .
- run: sbt test
- run: sbt "scalafix --check OrganizeImports"
build:
name: Build and push Docker
permissions:
packages: write
runs-on: ubuntu-latest
needs: test
concurrency:
group: cicd-build-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- uses: coursier/cache-action@v6
- uses: sbt/setup-sbt@v1
- uses: VirtusLab/scala-cli-setup@v1
with:
jvm: 21
- run: mkdir ./target
- run: scala-cli --power package --standalone . --output ./target/dawn-patrol
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/dawn-patrol
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=pr-${{ github.event.pull_request.number }}-,priority=601,enable=${{ github.event_name == 'pull_request' }}
type=sha,prefix={{branch}}-,priority=601,enable=${{ github.event_name == 'push' && github.ref_type == 'branch' }}
type=ref,event=branch,priority=600
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=build
type=registry,ref=${{ env.REGISTRY }}/dawn-patrol:latest
cache-to: type=gha,mode=max,scope=build