forked from Linbreux/wikmd
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (105 loc) · 3 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: docker
on:
push:
tags:
- '*'
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
outputs:
wikmd_tags: ${{ steps.meta.outputs.tags }}
json: ${{ steps.meta.outputs.json }}
strategy:
matrix:
architecture:
- linux/amd64
# - linux/arm64
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: linbreux/wikmd
tags: |
type=ref,event=pr
type=ref,event=tag
type=edge
- name: Check docker image tag
run: echo "Creating Docker image ${{ steps.meta.outputs.tags }}"
- name: Build & export
uses: docker/build-push-action@v3
with:
file: docker/Dockerfile
push: false
tags: ${{ steps.meta.outputs.tags }}
outputs: type=docker,dest=/tmp/wikmd.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: wikmd
path: /tmp/wikmd.tar
test:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
tag: ${{ fromJSON(needs.build.outputs.json).tags }}
name: "test-${{ matrix.tag }}"
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: wikmd
path: /tmp
- name: Load image
run: |
docker load --input /tmp/wikmd.tar
docker image ls -a
# Start a default wikmd container
- name: Start wikmd
run: docker run -d --name wikmd -p 5000:5000 ${{ matrix.tag }}
# Wait for wikmd to be up and running
- name: Sleep
uses: jakejarvis/wait-action@master
with:
time: '20s'
# Print some debugging
- name: Check running containers
run: docker ps -a
- name: Check docker logs
run: docker logs wikmd
# Check that wikmd is up and running
- name: Assert wikmd status
run: curl -I localhost:5000 2>&1 | awk '/HTTP\// {print $2}' | grep -w "200\|301"
publish:
# Publish if official repo and push to 'main' or new tag
if: |
github.repository == 'Linbreux/wikmd' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
needs: [build, test]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish
uses: docker/build-push-action@v3
with:
file: docker/Dockerfile
push: true
tags: ${{ needs.build.outputs.wikmd_tags }}