Repository navigation
106 lines (89 loc) · 3.13 KB
/
Copy pathci.yml
File metadata and controls
106 lines (89 loc) · 3.13 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
cache: true
- name: Download GeoLite2 City database
env:
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
run: |
mkdir -p data
wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENSE_KEY&suffix=tar.gz" | tar xz -C data
cp data/GeoLite2-City_*/GeoLite2-City.mmdb data/GeoLite2-City.mmdb
- name: go vet
run: go vet ./...
- name: go test
run: go test ./...
- name: Upload GeoLite2 artifact
uses: actions/upload-artifact@v4
with:
name: geolite2-city-mmdb
path: data/GeoLite2-City.mmdb
if-no-files-found: error
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.11.3
docker-build:
runs-on: ubuntu-latest
name: Docker Build
timeout-minutes: 20
needs: [ test, lint ]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download GeoLite2 artifact
uses: actions/download-artifact@v4
with:
name: geolite2-city-mmdb
path: data
- name: Build Docker image (no push)
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: processing:pr-${{ github.sha }}
- name: Login to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/processing:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/processing:latest
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/processing:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/processing:buildcache,mode=max