-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (75 loc) · 2.09 KB
/
main.yaml
File metadata and controls
80 lines (75 loc) · 2.09 KB
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
name: Test-Build-Publish
on:
workflow_dispatch:
push:
branches: [main]
paths:
- "main.go"
- "go.*"
- "Makefile"
- "*.yaml"
- "src/**"
- Dockerfile
- "migrations/**"
jobs:
lint:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
test:
runs-on: self-hosted
needs: lint
env:
PASSPHRASE: test_passphrase
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_DB: test_db
APP_PORT: 8000
services:
db:
image: postgres:16.2-alpine3.19
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Running database migrations
run: docker run --rm --network host -v $(pwd)/migrations/migration:/flyway/sql flyway/flyway -url=jdbc:postgresql://localhost:5432/test_db -driver=org.postgresql.Driver -postgresql.transactional.lock=false -user=test_user -password=test_password migrate
- name: Running Tests
run: make test
build-push:
runs-on: self-hosted
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
target: production
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/tokeniser:1.0.0