-
-
Notifications
You must be signed in to change notification settings - Fork 1
157 lines (129 loc) · 3.96 KB
/
ci.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: CI
on:
push:
branches: [master]
paths-ignore:
- "**/README.md"
- "**/.github/images/**"
pull_request:
branches: [master]
paths-ignore:
- "**/README.md"
- "**/.github/images/**"
jobs:
# check our go files
go-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
stable: "false"
go-version: "1.23"
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
golangci-lint run
# check our dockerfiles
dockerfile-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint Dockerfile
uses: hadolint/hadolint-action@master
with:
dockerfile: "Dockerfile"
# make sure our tests are passing
test:
strategy:
matrix:
go-version: [1.22.x, 1.23.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Tidy
run: go mod tidy
- name: Test
run: go test -v ./...
# make sure go build works on various OS/Go versions
build:
strategy:
matrix:
go-version: [1.22.x, 1.23.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
# only run this job if the "test" job has passed
needs: [test]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.23"
- name: Build
run: go build -v ./...
# build and push image to docker registries
# (github packages & docker hub)
docker-build-push-image:
runs-on: ubuntu-latest
# oonly build/push image if the build job passed
needs: [build]
# don't push on pull requests
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
flavor: |
latest=true
tags: |
type=raw,enable=true,value=latest
images: |
hivacruz/moviestills
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Uploading the README.md is not a core feature of docker/build-push-action yet
- name: push README to Dockerhub
uses: christian-korneck/update-container-description-action@v1
env:
DOCKER_USER: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASS: ${{ secrets.DOCKERHUB_PASS }}
with:
destination_container_repo: hivacruz/moviestills
provider: dockerhub
short_description: "Docker image for moviestills, a small CLI app to download movie snapshots."
readme_file: "README.md"