Skip to content

Commit ffbd839

Browse files
committed
Automate publishing of Docker images
1 parent b648ec3 commit ffbd839

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

.github/workflows/publish.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Versioning
1+
name: Publish
22
on:
33
push:
44
tags:
55
- 'v*'
66
jobs:
7-
publish:
7+
release:
88
name: Publish Release
99
runs-on: ubuntu-18.04
1010
steps:
@@ -49,7 +49,7 @@ jobs:
4949
tag_name: ${{ github.ref }}
5050
release_name: v${{ steps.build.outputs.version }}
5151
body: ${{ steps.build.outputs.release_body }}
52-
draft: true
52+
draft: false
5353
prerelease: false
5454
- name: Upload Asset (darwin)
5555
uses: actions/[email protected]
@@ -78,3 +78,42 @@ jobs:
7878
asset_path: ./tmp/build/${{ steps.build.outputs.filename_windows }}
7979
asset_name: ${{ steps.build.outputs.filename_windows }}
8080
asset_content_type: application/octet-stream
81+
docker:
82+
name: Publish Docker
83+
runs-on: ubuntu-18.04
84+
needs:
85+
- release
86+
env:
87+
IMAGE_NAME: gget
88+
steps:
89+
- name: Prepare
90+
id: prepare
91+
run: |
92+
version="$( echo "${{ github.ref }}" | sed 's#refs/tags/v##' )"
93+
echo ::set-output name=version::"$version"
94+
95+
image=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
96+
echo ::set-output name=image::"$image"
97+
- uses: actions/checkout@v1
98+
- name: Build Image
99+
run: |
100+
docker build build/docker/$IMAGE_NAME \
101+
--build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
102+
--build-arg GGET_REF=github.com/${{ github.repository }} \
103+
--build-arg GGET_VERSION=v${{ steps.prepare.outputs.version }} \
104+
--tag image
105+
- name: Registry Login
106+
run: |
107+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
108+
- name: Publish Images
109+
run: |
110+
for tag in \
111+
${{ steps.prepare.outputs.version }} \
112+
$( echo "${{ steps.prepare.outputs.version }}" | cut -d. -f1-2 ) \
113+
$( echo "${{ steps.prepare.outputs.version }}" | cut -d. -f1 ) \
114+
latest \
115+
; do
116+
fqimagetag="${{ steps.prepare.outputs.image }}:v$tag"
117+
docker tag image $fqimagetag
118+
docker push $fqimagetag
119+
done

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ go get -u github.com/dpb587/gget
6868

6969
## Docker Usage
7070

71-
The `dpb587/gget` image can be used as a build stage for finding and downloading assets for use in a subsequent stage.
71+
The `gget` image can be used as a build stage for finding and downloading assets for use in a subsequent stage.
7272

7373
```
74-
FROM dpb587/gget as gget
74+
FROM docker.pkg.github.com/dpb587/private/gget as gget
7575
RUN gget --executable github.com/cloudfoundry/bosh-cli bosh=bosh-cli-*-linux-amd64
7676
RUN gget --executable github.com/cloudfoundry/bosh-bootloader bbl=bbl-*_linux_x86-64
7777
RUN gget --stdout github.com/pivotal-cf/om om-linux-*.tar.gz | tar -xzf- om

build/docker/gget/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
FROM alpine as base
22
RUN apk add --no-cache ca-certificates wget
33

4+
ARG GGET_VERSION
5+
ARG GGET_REF
6+
ARG GITHUB_TOKEN
47
ENV gget /usr/local/bin/gget
58
RUN true \
69
&& wget -qO "$gget" https://github.com/dpb587/gget/releases/download/v0.1.0/gget-0.1.0-linux-amd64 \
710
&& echo "418b68caeb302898322465abc31c316a1dbdb7872cdad0fe4a9661c5118860c4 $gget" | sha256sum -c \
811
&& chmod +x "$gget"
9-
RUN gget github.com/dpb587/gget --executable "$gget=gget-*-linux-amd64"
12+
RUN gget --exec ${GGET_REF:-github.com/dpb587/gget}@${GGET_VERSION:-} "$gget=gget-*-linux-amd64"
1013
RUN gget --version -v
1114

1215
FROM alpine

docs/releases/v0.2.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
* Renames `--exec` to `--executable`
22
* Fixes panic when parsing some release notes for checksums.
3+
* Automate publishing of Docker images on GitHub Packages.

0 commit comments

Comments
 (0)