forked from caddy-dns/cloudflare
-
Notifications
You must be signed in to change notification settings - Fork 3
88 lines (77 loc) · 2.24 KB
/
continuous-integration.yml
File metadata and controls
88 lines (77 loc) · 2.24 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
name: Continuous Integration
on:
schedule:
- cron: "0 7 * * *"
push:
branches:
- main
- master
tags:
- '*'
pull_request:
branches:
- main
- master
jobs:
go-build-and-test:
runs-on: ubuntu-latest
name: "Run go tests"
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.2'
check-latest: true
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: go build -v
- name: Test
run: go test -v
build-with-xcaddy-and-push:
runs-on: ubuntu-latest
name: "Build with xcaddy and push to GHCR"
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- uses: actions/checkout@v4
- name: Log in to GHCR (tags only)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set image tags
id: tags
run: |
if [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref }}" == refs/tags/* ]]; then
{
echo "tags<<EOF"
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}"
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
echo "EOF"
} >> $GITHUB_OUTPUT
else
echo "tags=caddy-cloudflare:local" >> $GITHUB_OUTPUT
fi
- name: Build Docker image with xcaddy and optionally push to GHCR
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.tags.outputs.tags }}