Skip to content

Commit 0946ad2

Browse files
Merge pull request #49 from PDOK/add-dockerbuild-action
Add dockerbuild github action
2 parents d221059 + a45a0f3 commit 0946ad2

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: build
2+
env:
3+
image: pdok/mapserver
4+
on:
5+
release:
6+
types:
7+
- [created]
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Docker meta
13+
id: docker_meta
14+
uses: docker/metadata-action@v3
15+
with:
16+
images: ${{ env.image }}
17+
tags: |
18+
type=semver,pattern={{major}}
19+
type=semver,pattern={{major}}.{{minor}}
20+
type=semver,pattern={{version}}
21+
- name: Login to PDOK Docker Hub
22+
if: startsWith(env.image, 'pdok/')
23+
uses: docker/login-action@v2
24+
with:
25+
username: koalapdok
26+
password: ${{ secrets.DOCKERHUB_PUSH }}
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
- name: Cache Docker layers
30+
uses: actions/cache@v2
31+
with:
32+
path: /tmp/.buildx-cache
33+
key: ${{ runner.os }}-buildx-${{ github.sha }}
34+
restore-keys: |
35+
${{ runner.os }}-buildx-
36+
- name: Build and push
37+
id: docker_build
38+
uses: docker/build-push-action@v3
39+
with:
40+
push: true
41+
tags: ${{ steps.docker_meta.outputs.tags }}
42+
file: ${{context}}/Dockerfile
43+
labels: ${{ steps.docker_meta.outputs.labels }}
44+
cache-from: type=local,src=/tmp/.buildx-cache
45+
cache-to: type=local,dest=/tmp/.buildx-cache-new
46+
- name: Build and push NL
47+
id: docker_build
48+
uses: docker/build-push-action@v3
49+
with:
50+
push: true
51+
tags: ${{ steps.docker_meta.outputs.tags }}-nl
52+
file: ${{context}}/Dockerfile.NL
53+
labels: ${{ steps.docker_meta.outputs.labels }}
54+
cache-from: type=local,src=/tmp/.buildx-cache
55+
cache-to: type=local,dest=/tmp/.buildx-cache-new
56+
- # Temp fix to cleanup cache
57+
# https://github.com/docker/build-push-action/issues/252
58+
# https://github.com/moby/buildkit/issues/1896
59+
name: Move cache
60+
run: |
61+
rm -rf /tmp/.buildx-cache
62+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
63+
- name: Build result notification
64+
if: success() || failure()
65+
uses: 8398a7/action-slack@v3
66+
with:
67+
fields: all
68+
status: custom
69+
custom_payload: |
70+
{
71+
attachments: [{
72+
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
73+
text: `${process.env.AS_WORKFLOW} ${{ job.status }} for ${process.env.AS_REPO}!\n${process.env.AS_JOB} job on ${process.env.AS_REF} (commit: ${process.env.AS_COMMIT}, version: ${{ steps.docker_meta.outputs.version }}) by ${process.env.AS_AUTHOR} took ${process.env.AS_TOOK}`,
74+
}]
75+
}
76+
env:
77+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)