-
Notifications
You must be signed in to change notification settings - Fork 1
122 lines (106 loc) · 3.92 KB
/
push-docker.yml
File metadata and controls
122 lines (106 loc) · 3.92 KB
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
122
name: build-tag-push
on:
schedule:
# At 00:00 on Sunday.
- cron: "0 0 * * 0"
push:
branches:
- main
env:
IMAGE_REPO: thspacecode
IMAGE_NAME: erpnext-docker
jobs:
build-tag-push:
runs-on: ubuntu-latest
strategy:
matrix:
app_branch: ["version-16"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build base image
uses: docker/build-push-action@v7
with:
context: "{{defaultContext}}:dockerfile"
target: base
tags: ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ matrix.app_branch }}-latest
push: false
load: true
build-args: |
APP_BRANCH=${{ matrix.app_branch }}
- name: Build pre-install image for smoke test
uses: docker/build-push-action@v7
with:
context: "{{defaultContext}}:dockerfile"
target: pre-install
tags: ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:PRE-${{ matrix.app_branch }}-latest
push: false
load: true
- name: Start container
run: |
docker run -d --name action-test -p 8000:80 \
${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:PRE-${{ matrix.app_branch }}-latest
- name: Wait until site is ready (max 5 min)
run: |
timeout=300
elapsed=0
until curl -sf -o /dev/null http://127.0.0.1:8000; do
if [ "$elapsed" -ge "$timeout" ]; then
echo "Timed out after ${timeout}s waiting for port 8000"
docker ps -a
docker logs action-test
exit 1
fi
sleep 5
elapsed=$((elapsed + 5))
echo "Waiting... ${elapsed}s elapsed"
done
docker ps -a
docker logs action-test
echo "Site is up after ${elapsed}s"
- name: Check HTTP Response
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8000)
if [ "$response" == 200 ]; then
echo "Received a 200 response!"
else
echo "Failed to receive a 200 response, got: $response"
exit 1
fi
- name: Getting app version from image
run: |
docker exec -u frappe action-test bench version > version.txt
- name: Formatting and set version variable
run: python ./.github/workflows/scripts/tag_image.py
- name: Tag and push
run: |
docker tag ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ matrix.app_branch }}-latest ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION_TAG }}
docker push ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION_TAG }}
docker push ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ matrix.app_branch }}-latest
- name: Build and push all-in-one image
uses: docker/build-push-action@v7
with:
context: "{{defaultContext}}:dockerfile"
target: all-in-one
tags: |
${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:ALL-${{ env.IMAGE_VERSION_TAG }}
${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:ALL-${{ matrix.app_branch }}-latest
push: true
- name: Build and push pre-install image
uses: docker/build-push-action@v7
with:
context: "{{defaultContext}}:dockerfile"
target: pre-install
tags: |
${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:PRE-${{ env.IMAGE_VERSION_TAG }}
${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:PRE-${{ matrix.app_branch }}-latest
push: true