1
1
name : CI
2
+
2
3
on :
3
- release :
4
- types :
5
- - published
6
4
push :
7
5
branches :
8
- - master
9
- paths :
10
- - .github/workflows/ci.yml
11
- - cmd/**
12
- - internal/**
13
- - pkg/**
14
- - .dockerignore
15
- - .golangci.yml
16
- - Dockerfile
17
- - go.mod
18
- - go.sum
6
+ - main
7
+ - develop
8
+ - release/*
9
+ - beta/*
10
+ tags :
11
+ - v*
19
12
pull_request :
20
- paths :
21
- - .github/workflows/ci.yml
22
- - cmd/**
23
- - internal/**
24
- - pkg/**
25
- - .dockerignore
26
- - .golangci.yml
27
- - Dockerfile
28
- - go.mod
29
- - go.sum
13
+ branches :
14
+ - main
15
+ - develop
16
+ - release/*
17
+ - beta/*
18
+ release :
19
+ types : [published]
20
+ workflow_dispatch :
30
21
31
22
jobs :
32
23
verify :
33
24
runs-on : ubuntu-latest
34
- permissions :
35
- actions : read
36
- contents : read
37
- env :
38
- DOCKER_BUILDKIT : " 1"
39
25
steps :
40
26
- uses : actions/checkout@v4
41
-
42
- - uses : reviewdog/action-misspell@v1
27
+ - uses : actions/setup-go@v5
43
28
with :
44
- locale : " US"
45
- level : error
46
- exclude : |
47
- ./internal/storage/servers.json
48
- *.md
49
-
50
- - name : Linting
51
- run : docker build --target lint .
52
-
53
- - name : Mocks check
54
- run : docker build --target mocks .
55
-
56
- - name : Build test image
57
- run : docker build --target test -t test-container .
58
-
59
- - name : Run tests in test container
60
- run : |
61
- touch coverage.txt
62
- docker run --rm --device /dev/net/tun \
63
- -v "$(pwd)/coverage.txt:/tmp/gobuild/coverage.txt" \
64
- test-container
65
-
66
- - name : Build final image
67
- run : docker build -t final-image .
29
+ go-version-file : go.mod
30
+ cache : true
31
+ - name : Verify
32
+ run : make verify
68
33
69
34
codeql :
35
+ name : CodeQL
70
36
runs-on : ubuntu-latest
71
37
permissions :
72
38
actions : read
73
39
contents : read
74
40
security-events : write
41
+
42
+ strategy :
43
+ fail-fast : false
44
+ matrix :
45
+ language : ["go"]
46
+
75
47
steps :
76
- - uses : actions/checkout@v4
77
- - uses : actions/setup-go@v5
78
- with :
79
- go-version : " ^1.23"
80
- - uses : github/codeql-action/init@v3
48
+ - name : Checkout repository
49
+ uses : actions/checkout@v4
50
+
51
+ # Initializes the CodeQL tools for scanning.
52
+ - name : Initialize CodeQL
53
+ uses : github/codeql-action/init@v3
81
54
with :
82
- languages : go
83
- - uses : github/codeql-action/autobuild@v3
84
- - uses : github/codeql-action/analyze@v3
55
+ languages : ${{ matrix.language }}
56
+ # If you wish to specify custom queries, you can do so here or in a config file.
57
+ # By default, queries listed here will override any specified in a config file.
58
+ # Prefix the list here with "+" to use these queries and queries in the config file.
59
+ # For more information on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-qlpacks
60
+
61
+ - name : Autobuild
62
+ uses : github/codeql-action/autobuild@v3
63
+
64
+ - name : Perform CodeQL Analysis
65
+ uses : github/codeql-action/analyze@v3
85
66
86
67
publish :
87
68
if : |
88
- github.repository == 'qdm12/gluetun' &&
89
69
(
90
70
github.event_name == 'push' ||
91
71
github.event_name == 'release' ||
109
89
flavor : |
110
90
latest=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
111
91
images : |
112
- ghcr.io/qdm12/gluetun
113
- qmcgaw/gluetun
114
- qmcgaw/private-internet-access
92
+ ghcr.io/${{ github.repository_owner }}/gluetun
93
+ ${{ github.repository_owner }}/gluetun
115
94
tags : |
116
95
type=ref,event=pr
117
96
type=semver,pattern=v{{major}}.{{minor}}.{{patch}}
@@ -122,20 +101,24 @@ jobs:
122
101
- uses : docker/setup-qemu-action@v3
123
102
- uses : docker/setup-buildx-action@v3
124
103
104
+ # Login to Docker Hub (optional, only if you want to push to Docker Hub)
125
105
- uses : docker/login-action@v3
106
+ if : github.event_name != 'pull_request'
126
107
with :
127
- username : qmcgaw
128
- password : ${{ secrets.DOCKERHUB_PASSWORD }}
108
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
109
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
129
110
111
+ # Login to GitHub Container Registry
130
112
- uses : docker/login-action@v3
113
+ if : github.event_name != 'pull_request'
131
114
with :
132
115
registry : ghcr.io
133
- username : qdm12
134
- password : ${{ github.token }}
116
+ username : ${{ github.actor }}
117
+ password : ${{ secrets.GITHUB_TOKEN }}
135
118
136
119
- name : Short commit
137
120
id : shortcommit
138
- run : echo "::set-output name= value:: $(git rev-parse --short HEAD)"
121
+ run : echo "value= $(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
139
122
140
123
- name : Build and push final image
141
124
uses : docker/build-push-action@v6
@@ -147,4 +130,4 @@ jobs:
147
130
COMMIT=${{ steps.shortcommit.outputs.value }}
148
131
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
149
132
tags : ${{ steps.meta.outputs.tags }}
150
- push : true
133
+ push : ${{ github.event_name != 'pull_request' }}
0 commit comments