Repository navigation
146 lines (135 loc) · 6.08 KB
/
Copy pathdocker.yml
File metadata and controls
146 lines (135 loc) · 6.08 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
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
name: Docker
on:
workflow_dispatch:
push:
branches:
- master
tags:
- 'lychee-v*'
pull_request:
branches:
- master
env:
IMAGE_NAME: lycheeverse/lychee
DOCKER_PLATFORMS: linux/amd64,linux/arm64/v8
DOCKERFILE: Dockerfile-CI.Dockerfile
DOCKERFILE_ALPINE: Dockerfile-CI.alpine.Dockerfile
jobs:
build:
runs-on: ubuntu-latest
if: github.repository_owner == 'lycheeverse' &&
github.actor != 'dependabot[bot]' &&
( github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login )
steps:
- name: Checkout
uses: actions/checkout@v7
# Docker tagging policy
# ----------------------
# - `latest` -> most recent stable release (release tag push only)
# - `X.Y.Z` / `X.Y` -> a specific release
# - `nightly`/`master` -> bleeding-edge build from the default branch
# - `sha-<sha>` -> a specific commit
# Each also gets an `-alpine` variant via the second metadata step.
#
# We intentionally set `flavor: latest=false` and add `latest` explicitly
# instead of relying on the default `latest=auto`. `auto` decides whether
# to apply `latest` by detecting a semver *git tag*, but our release tags
# are prefixed (`lychee-v1.2.3`) and the version is only recovered via the
# `match=` regex, so `auto`'s detection is unreliable here. Gating `latest`
# on the release-tag ref ourselves is the documented, predictable approach:
# https://github.com/docker/metadata-action#latest-tag
# Note: this gate assumes all `lychee-v*` tags are stable. If pre-release
# tags are ever introduced, also exclude them here (e.g. `!contains(github.ref, '-')`).
- name: Docker meta (debian)
id: meta
uses: docker/metadata-action@v6
with:
# See the tagging-policy note above for why latest=false.
flavor: |
latest=false
# list of Docker images to use as base name for tags
images: |
${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ github.ref_name }},match=lychee-v(\d+.\d+.\d+)$
type=semver,pattern={{major}}.{{minor}},value=${{ github.ref_name }},match=lychee-v(\d+.\d+.\d+)$
type=sha
# `latest` points to the most recent stable release (tag push only)
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/lychee-v') }}
# `nightly` tracks the bleeding-edge build from the default branch
type=raw,value=nightly,enable={{is_default_branch}}
- name: Docker meta (alpine)
id: meta-alpine
uses: docker/metadata-action@v6
with:
# A global suffix for each generated tag.
# See the tagging-policy note above for why latest=false.
flavor: |
latest=false
suffix=-alpine
# list of Docker images to use as base name for tags
images: |
${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ github.ref_name }},match=lychee-v(\d+.\d+.\d+)$
type=semver,pattern={{major}}.{{minor}},value=${{ github.ref_name }},match=lychee-v(\d+.\d+.\d+)$
type=sha
# `latest` points to the most recent stable release (tag push only)
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/lychee-v') }}
# `nightly` tracks the bleeding-edge build from the default branch
type=raw,value=nightly,enable={{is_default_branch}}
# Debug step to see generated tags
- name: Show tags
run: |
echo "Tags for debian: ${{ steps.meta.outputs.tags }}"
echo "Tags for alpine: ${{ steps.meta-alpine.outputs.tags }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Image (debian)
uses: docker/build-push-action@v7
with:
context: .
file: ${{ env.DOCKERFILE }}
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ (github.event_name != 'pull_request' &&
github.actor != 'dependabot[bot]') ||
startsWith(github.ref, 'lychee-v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"LYCHEE_VERSION=${{ github.ref == 'refs/heads/master' && 'nightly' || (startsWith(github.ref, 'refs/tags/lychee-v') && github.ref_name || 'latest') }}"
- name: Push Image (alpine)
uses: docker/build-push-action@v7
with:
context: .
file: ${{ env.DOCKERFILE_ALPINE }}
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ (github.event_name != 'pull_request' &&
github.actor != 'dependabot[bot]') ||
startsWith(github.ref, 'lychee-v') }}
tags: ${{ steps.meta-alpine.outputs.tags }}
labels: ${{ steps.meta-alpine.outputs.labels }}
build-args: |
"LYCHEE_VERSION=${{ github.ref == 'refs/heads/master' && 'nightly' || (startsWith(github.ref, 'refs/tags/lychee-v') && github.ref_name || 'latest') }}"
- name: Update DockerHub description
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: lycheeverse/lychee
readme-filepath: README.md