forked from opensalt/opensalt
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (107 loc) · 4.27 KB
/
build.yml
File metadata and controls
120 lines (107 loc) · 4.27 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
on:
push:
release:
types: [published]
name: Build and Test
jobs:
build:
name: Build OpenSALT
runs-on: ubuntu-latest
env:
COMPOSE_FILE: "docker-compose.yml:docker-compose.test.yml"
RUN_TEST_ARGS: ${{ secrets.RUN_TEST_ARGS }}
DEFAULT_RUN_TEST_ARGS: "--fail-fast --steps -x duplicate -x skip -x skip-firefox -x 0117-0708 -x 0108-0801 -x 1013-1444 -x change-notification"
steps:
- name: Checkout
uses: actions/checkout@v2
# https://github.com/marketplace/actions/docker-layer-caching
# Pull the latest image to build, and avoid caching pull-only images.
# (docker pull is faster than caching in most cases.)
- name: Pull images
env:
REPO: opensalt/opensalt
run: |
env
cp -f .env.test .env
docker pull $REPO:core-develop
docker pull $REPO:web-develop
docker pull $REPO:cron-develop
docker pull $REPO:db-develop
# # In this step, this action saves a list of existing images,
# # the cache is created without them in the post run.
# # It also restores the cache if it exists.
# - name: Cache docker layers
# uses: satackey/action-docker-layer-caching@v0.0.11
# # Ignore the failure of a step and avoid terminating the job.
# continue-on-error: true
# with:
# key: opensalt-docker-cache-{hash}
# restore-keys: |
# opensalt-docker-cache-
- name: Build the images
run: |
BUILD_NUMBER=${GITHUB_RUN_NUMBER} COMMIT=${GITHUB_SHA::8} make docker-build
- name: Bring up the stack
run: |
docker-compose up -d
docker-compose exec -T php dockerize -timeout 60s -wait tcp://db:3306 && sleep 5
- name: Initialize db
run: |
./core/bin/console --env=prod doctrine:migrations:migrate -q --no-interaction
./core/bin/console --env=prod import:generic-csv tests/_data/test_items.csv
- name: Run tests
run: ./core/bin/run-tests ${RUN_TEST_ARGS:-$DEFAULT_RUN_TEST_ARGS}
- name: Failed
if: ${{ failure() }}
run: |
docker-compose logs php web
- name: Login to DockerHub
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || github.event_name == 'release'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push develop
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
env:
REPO: opensalt/opensalt
run: |
docker tag opensalt/opensalt:core-3.x $REPO:core-develop
docker tag opensalt/opensalt:web-3.x $REPO:web-develop
docker tag opensalt/opensalt:cron-3.x $REPO:cron-develop
docker tag opensalt/opensalt:db-3.x $REPO:db-develop
docker push $REPO:core-develop
docker push $REPO:web-develop
docker push $REPO:cron-develop
docker push $REPO:db-develop
- name: Push latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
env:
REPO: opensalt/opensalt
run: |
docker tag opensalt/opensalt:core-3.x $REPO:core-latest
docker tag opensalt/opensalt:web-3.x $REPO:web-latest
docker tag opensalt/opensalt:cron-3.x $REPO:cron-latest
docker tag opensalt/opensalt:db-3.x $REPO:db-latest
docker push $REPO:core-latest
docker push $REPO:web-latest
docker push $REPO:cron-latest
docker push $REPO:db-latest
- name: Push release
if: github.event_name == 'release'
env:
REPO: opensalt/opensalt
TAG: ${GITHUB_REF/refs\/tags\//}
run: |
docker tag opensalt/opensalt:core-3.x $REPO:core-${TAG}
docker tag opensalt/opensalt:web-3.x $REPO:web-${TAG}
docker tag opensalt/opensalt:cron-3.x $REPO:cron-${TAG}
docker tag opensalt/opensalt:db-3.x $REPO:db-${TAG}
docker push $REPO:core-${TAG}
docker push $REPO:web-${TAG}
docker push $REPO:cron-${TAG}
docker push $REPO:db-${TAG}
- name: Bring down the stack
if: ${{ always() }}
run: |
docker-compose down -v