Skip to content

Commit 094b758

Browse files
committed
Publish to GHCR
1 parent 02ef9e5 commit 094b758

File tree

3 files changed

+47
-47
lines changed

3 files changed

+47
-47
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: build
33
on:
44
push:
55
branches:
6-
- 'master'
7-
- 'v*'
6+
- '**'
87
tags:
98
- 'v*'
109
paths-ignore:
@@ -23,7 +22,6 @@ on:
2322
- 'mkdocs.yml'
2423

2524
jobs:
26-
2725
go:
2826
runs-on: ubuntu-latest
2927
steps:
@@ -84,28 +82,24 @@ jobs:
8482
docker:
8583
runs-on: ubuntu-latest
8684
needs: go
85+
env:
86+
DOCKERHUB_SLUG: crazymax/ftpgrab
87+
GHCR_SLUG: ghcr.io/crazy-max/ftpgrab
8788
steps:
8889
-
8990
name: Checkout
9091
uses: actions/[email protected]
9192
-
92-
name: Prepare
93-
id: prep
94-
run: |
95-
DOCKER_IMAGE=crazymax/ftpgrab
96-
VERSION=edge
97-
if [[ $GITHUB_REF == refs/tags/* ]]; then
98-
VERSION=${GITHUB_REF#refs/tags/v}
99-
fi
100-
TAGS="${DOCKER_IMAGE}:${VERSION}"
101-
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
102-
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
103-
fi
104-
echo ::set-output name=docker_image::${DOCKER_IMAGE}
105-
echo ::set-output name=version::${VERSION}
106-
echo ::set-output name=tags::${TAGS}
107-
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
108-
echo ::set-output name=vcs_ref::${GITHUB_SHA::8}
93+
name: Docker meta
94+
id: docker_meta
95+
uses: crazy-max/ghaction-docker-meta@v1
96+
with:
97+
images: |
98+
${{ env.DOCKERHUB_SLUG }}
99+
${{ env.GHCR_SLUG }}
100+
tag-edge: true
101+
tag-match: v(.*)
102+
tag-match-group: 1
109103
-
110104
name: Set up QEMU
111105
uses: docker/setup-qemu-action@v1
@@ -121,26 +115,41 @@ jobs:
121115
with:
122116
username: ${{ secrets.DOCKER_USERNAME }}
123117
password: ${{ secrets.DOCKER_PASSWORD }}
118+
-
119+
name: Login to GHCR
120+
if: github.event_name != 'pull_request'
121+
uses: docker/[email protected]
122+
with:
123+
registry: ghcr.io
124+
username: ${{ secrets.GHCR_USERNAME }}
125+
password: ${{ secrets.GHCR_TOKEN }}
124126
-
125127
name: Build
126128
uses: docker/build-push-action@v2
127129
with:
128130
context: .
129131
file: ./Dockerfile
130132
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
131-
push: ${{ github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) }}
132-
tags: ${{ steps.prep.outputs.tags }}
133+
push: ${{ github.event_name != 'pull_request' }}
134+
tags: ${{ steps.docker_meta.outputs.tags }}
133135
build-args: |
134-
VERSION=${{ steps.prep.outputs.version }}
135-
BUILD_DATE=${{ steps.prep.outputs.build_date }}
136-
VCS_REF=${{ steps.prep.outputs.vcs_ref }}
136+
VERSION=${{ steps.docker_meta.outputs.version }}
137+
labels: |
138+
${{ steps.docker_meta.outputs.labels }}
139+
org.opencontainers.image.title=FTPGrab
140+
org.opencontainers.image.description=Grab your files periodically from a remote FTP or SFTP server easily
141+
org.opencontainers.image.vendor=CrazyMax
137142
-
138143
name: Check manifest
139-
if: github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
144+
if: github.event_name != 'pull_request'
140145
run: |
141-
docker buildx imagetools inspect ${{ steps.prep.outputs.docker_image }}:${{ steps.prep.outputs.version }}
146+
docker buildx imagetools inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.docker_meta.outputs.version }}
147+
docker buildx imagetools inspect ${{ env.GHCR_SLUG }}:${{ steps.docker_meta.outputs.version }}
142148
-
143-
name: Check pull
144-
if: github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
149+
name: Inspect image
150+
if: github.event_name != 'pull_request'
145151
run: |
146-
docker pull ${{ steps.prep.outputs.docker_image }}:${{ steps.prep.outputs.version }}
152+
docker pull ${{ env.DOCKERHUB_SLUG }}:${{ steps.docker_meta.outputs.version }}
153+
docker image inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.docker_meta.outputs.version }}
154+
docker pull ${{ env.GHCR_SLUG }}:${{ steps.docker_meta.outputs.version }}
155+
docker image inspect ${{ env.GHCR_SLUG }}:${{ steps.docker_meta.outputs.version }}

Dockerfile

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
FROM --platform=${BUILDPLATFORM:-linux/amd64} tonistiigi/xx:golang AS xgo
22
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-alpine AS builder
33

4-
ARG BUILD_DATE
5-
ARG VCS_REF
64
ARG VERSION=dev
75

86
ENV CGO_ENABLED 0
@@ -30,20 +28,7 @@ RUN go build -ldflags "-w -s -X 'main.version=${VERSION}'" -v -o ftpgrab cmd/mai
3028

3129
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:latest
3230

33-
ARG BUILD_DATE
34-
ARG VCS_REF
35-
ARG VERSION
36-
37-
LABEL maintainer="CrazyMax" \
38-
org.opencontainers.image.created=$BUILD_DATE \
39-
org.opencontainers.image.url="https://github.com/crazy-max/ftpgrab" \
40-
org.opencontainers.image.source="https://github.com/crazy-max/ftpgrab" \
41-
org.opencontainers.image.version=$VERSION \
42-
org.opencontainers.image.revision=$VCS_REF \
43-
org.opencontainers.image.vendor="CrazyMax" \
44-
org.opencontainers.image.title="FTPGrab" \
45-
org.opencontainers.image.description="Grab your files periodically from a remote FTP or SFTP server easily" \
46-
org.opencontainers.image.licenses="MIT"
31+
LABEL maintainer="CrazyMax"
4732

4833
RUN apk --update --no-cache add \
4934
ca-certificates \

docs/install/docker.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
## About
44

5-
FTPGrab provides automatically updated Docker :whale: images within [Docker Hub](https://hub.docker.com/r/crazymax/ftpgrab).
5+
FTPGrab provides automatically updated Docker :whale: images within several registries:
6+
7+
| Registry | Image |
8+
|--------------------------------------------------------------------------------------------------|---------------------------------|
9+
| [Docker Hub](https://hub.docker.com/r/crazymax/ftpgrab/) | `crazymax/ftpgrab` |
10+
| [GitHub Container Registry](https://github.com/users/crazy-max/packages/container/package/ftpgrab) | `ghcr.io/crazy-max/ftpgrab` |
11+
612
It is possible to always use the latest stable tag or to use another service that handles updating Docker images.
713

814
!!! note

0 commit comments

Comments
 (0)