-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (92 loc) · 2.71 KB
/
publish-image.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
96
97
98
99
100
101
102
103
104
105
106
107
108
name: CI
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
release:
types: [ published ]
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Install dependencies
run: go mod download
- name: Verify module integrity
run: go mod tidy
- name: Run tests
run: go test -v ./...
release:
name: Release
runs-on: ubuntu-latest
if: github.event_name != 'release'
needs: test
permissions:
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '21'
- name: Install semantic-release
run: npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/release-notes-generator @semantic-release/exec
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: semantic-release
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: triargos/webdav-go
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
if : github.event.release.prerelease == false
with:
platforms: linux/arm64,linux/amd64
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Push prerelease Docker image
if: github.event.release.prerelease == true
uses: docker/build-push-action@v5
with:
platforms: linux/arm64,linux/amd64
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}-prerelease
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max