Skip to content

Commit 5534a7f

Browse files
committed
add a github action to publish a docker container for ws
1 parent efb2452 commit 5534a7f

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.github/workflows/docker.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: docker
2+
3+
# When its time to do a release do a build for amd64
4+
# and push all of them to Docker Hub.
5+
# Only trigger on semver shaped tags.
6+
on:
7+
push:
8+
tags:
9+
- "v*.*.*"
10+
11+
jobs:
12+
login:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Prepare
19+
id: prep
20+
run: |
21+
DOCKER_IMAGE=machinezone/ws
22+
VERSION=edge
23+
if [[ $GITHUB_REF == refs/tags/* ]]; then
24+
VERSION=${GITHUB_REF#refs/tags/v}
25+
fi
26+
if [ "${{ github.event_name }}" = "schedule" ]; then
27+
VERSION=nightly
28+
fi
29+
TAGS="${DOCKER_IMAGE}:${VERSION}"
30+
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
31+
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
32+
fi
33+
echo ::set-output name=tags::${TAGS}
34+
35+
- name: Set up Docker Buildx
36+
id: buildx
37+
uses: docker/setup-buildx-action@master
38+
39+
- name: Cache Docker layers
40+
uses: actions/cache@v2
41+
with:
42+
path: /tmp/.buildx-cache
43+
key: ${{ runner.os }}-buildx-${{ github.sha }}
44+
restore-keys: |
45+
${{ runner.os }}-buildx-
46+
47+
- name: Login to GitHub Package Registry
48+
uses: docker/login-action@v1
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.repository_owner }}
52+
password: ${{ secrets.GHCR_TOKEN }}
53+
54+
- name: Build and push
55+
id: docker_build
56+
uses: docker/build-push-action@v2-build-push
57+
with:
58+
builder: ${{ steps.buildx.outputs.name }}
59+
context: .
60+
file: ./Dockerfile
61+
target: prod
62+
platforms: linux/amd64
63+
push: ${{ github.event_name != 'pull_request' }}
64+
tags: ${{ steps.prep.outputs.tags }}
65+
cache-from: type=local,src=/tmp/.buildx-cache
66+
cache-to: type=local,dest=/tmp/.buildx-cache

0 commit comments

Comments
 (0)