-
-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (64 loc) · 2.01 KB
/
build.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
---
name: Build
on:
pull_request:
push:
branches:
- master
schedule:
- cron: "15 2 * * 0"
env:
ANSIBLE_FORCE_COLOR: true
jobs:
# Test the images build and work correctly.
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install prerequisites.
run: pip3 install ansible docker six
- name: Install role dependencies.
run: ansible-galaxy install -r requirements.yml
- name: Build the image.
run: ansible-playbook main.yml
- name: Run the image and test it.
run: |
docker run -d --name=fathom -p 9000:9000 geerlingguy/fathom:latest
sleep 5
curl localhost:9000
- name: Store image artifact.
uses: ishworkh/docker-image-artifact-upload@v1
with:
image: "geerlingguy/fathom:latest"
# If on master branch, build and release images.
release:
name: Release
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Download image artifact.
uses: ishworkh/docker-image-artifact-download@v1
with:
image: "geerlingguy/fathom:latest"
- name: List all images for debugging.
run: docker images
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push images.
run: |
# Push latest tag.
docker push geerlingguy/fathom:latest
# Push current version tag.
fathom_version=$(docker run --rm geerlingguy/fathom:latest bash -c "fathom --version" | awk '{print $3}' | sed 's/.$//')
docker tag geerlingguy/fathom:latest geerlingguy/fathom:${fathom_version}
docker push geerlingguy/fathom:${fathom_version}