-
Notifications
You must be signed in to change notification settings - Fork 122
82 lines (68 loc) · 2.27 KB
/
push-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
name: build-tag-push
on:
schedule:
# At 00:00 on Sunday.
- cron: '0 0 * * 0'
push:
branches:
- master
env:
IMAGE_REPO: pipech
IMAGE_NAME: erpnext-docker-debian
jobs:
build-tag-push:
runs-on: ubuntu-latest
strategy:
matrix:
app_branch: [version-14, version-15]
steps:
- name: Generate action image action tag
run: echo "IMAGE_ACTION_TAG=${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ github.actor_id }}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and export to Docker
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ${{ env.IMAGE_ACTION_TAG }}
build-args: |
appBranch=${{ matrix.app_branch }}
- name: Start container
run: |
docker run -d -p 8000:8000 -p 9000:9000 --name "TEST_CONTAINER" "${{ env.IMAGE_ACTION_TAG }}"
- name: Wait for 2 minutes and check status
run: |
sleep 180s
docker ps -a
docker logs TEST_CONTAINER
docker inspect TEST_CONTAINER
- 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 TEST_CONTAINER bench version > version.txt
- name: Formatting and set version variable
run: python ./scripts/tag_image.py
- name: Tag and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION_TAG }},${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ matrix.app_branch }}-latest