Skip to content

Commit 5fe94b8

Browse files
bryanlattenBryan Latten
andauthored
Github Actions: added PR builder and release hub push (#67)
* Github Actions: added PR builder and release hub push * README: updated release management docs * Main: enable variant-less build and latest Co-authored-by: Bryan Latten <[email protected]>
1 parent a00ed1a commit 5fe94b8

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

.github/workflows/main.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: main
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
pull_request:
8+
branches: [ master ]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
env:
14+
IMAGE_BASE: behance/docker-base
15+
strategy:
16+
matrix:
17+
props:
18+
# This is the default variant-less distribution (ex. 3.2.1)
19+
- Dockerfile: Dockerfile-ubuntu-20.04
20+
# Variant distributions below all have semantic versions + suffix (ex. 3.2.1-ubuntu-18.04)
21+
- Dockerfile: Dockerfile-ubuntu-18.04
22+
suffix: ubuntu-18.04
23+
- Dockerfile: Dockerfile-ubuntu-20.04
24+
suffix: ubuntu-20.04
25+
- Dockerfile: Dockerfile-alpine
26+
suffix: alpine
27+
- Dockerfile: Dockerfile-centos-7
28+
suffix: centos-7
29+
- Dockerfile: Dockerfile-centos-8
30+
suffix: centos-8
31+
steps:
32+
-
33+
name: Checkout
34+
uses: actions/checkout@v2
35+
-
36+
name: Add tag suffix
37+
if: matrix.props.suffix
38+
run: |
39+
echo TAG_SUFFIX="-${{ matrix.props.suffix }}" >> $GITHUB_ENV
40+
-
41+
name: Docker meta
42+
id: meta
43+
if: github.event_name != 'pull_request'
44+
uses: docker/metadata-action@v3
45+
with:
46+
images: ${{ env.IMAGE_BASE }}
47+
tags: |
48+
type=semver,pattern={{major}}.{{minor}}.{{patch}}
49+
type=semver,pattern={{major}}.{{minor}}
50+
type=semver,pattern={{major}}
51+
flavor: |
52+
latest=auto
53+
suffix=${{ env.TAG_SUFFIX }}
54+
-
55+
name: Set up QEMU
56+
uses: docker/setup-qemu-action@v1
57+
-
58+
name: Set up Docker Buildx
59+
uses: docker/setup-buildx-action@v1
60+
-
61+
name: Login to DockerHub
62+
if: github.event_name != 'pull_request'
63+
uses: docker/login-action@v1
64+
with:
65+
username: ${{ secrets.DOCKERHUB_USERNAME }}
66+
password: ${{ secrets.DOCKERHUB_TOKEN }}
67+
-
68+
name: Build + push
69+
uses: docker/build-push-action@v2
70+
with:
71+
context: .
72+
platforms: linux/amd64,linux/arm64
73+
file: ${{ matrix.props.Dockerfile }}
74+
tags: ${{ steps.meta.outputs.tags }}
75+
push: ${{ github.event_name != 'pull_request' }}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,15 @@ Directory | Use
132132
`/etc/services-available/` | same as above, but must be symlinked into `/etc/services.d/` to take effect
133133
`/run.d/` | shell scripts (ending in .sh) that make runtime modifications ahead of S6 initialization
134134
`/scripts` | convenience scripts that can be leveraged in derived images
135+
136+
### Release Management
137+
138+
Github actions provide the machinery for producing tags distributed through Docker Hub. Once a tested and approved PR is merged, simply cutting a new semantically-versioned tag will generate the following matrix of tagged builds:
139+
- `[major].[minor].[patch](?-variant)`
140+
- `[major].[minor](?-variant)`
141+
- `[major](?-variant)`
142+
Platform support is available for architectures:
143+
- `linux/arm64`
144+
- `linux/amd64`
145+
146+
To add new variant based on a new Dockerfile, add an entry to the `matrix.props` with its file and variant suffix.

0 commit comments

Comments
 (0)