forked from EC-CUBE/ec-cube
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (133 loc) · 4.77 KB
/
dockerbuild.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Testing dockerbuild
on:
push:
paths:
- '**'
- '!*.md'
release:
types: [ published ]
env:
REGISTRY: ghcr.io
jobs:
dockerbuild:
name: dockerbuild
runs-on: ${{ matrix.operating-system }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-22.04 ]
php: [ '7.4', '8.0', '8.1' ]
db: [ pgsql ]
group: [ admin01 ]
include:
- db: pgsql
database_url: postgres://dbuser:[email protected]:15432/eccubedb
database_server_version: 14
- group: admin01
app_env: 'codeception'
- php: '7.4'
tag: '7.4-apache'
- php: '8.0'
tag: '8.0-apache'
- php: '8.1'
tag: '8.1-apache'
steps:
- name: downcase REPO
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}-php" >> ${GITHUB_ENV}
- name: Checkout
uses: actions/checkout@master
## Used when creating multi-platform images
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
- name: Setup PHP
uses: nanasess/setup-php@master
with:
php-version: ${{ matrix.php }}
- name: Initialize Composer
uses: ./.github/actions/composer
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# set latest tag for default branch
type=raw,value=${{ matrix.php }}-apache,prefix=,enable={{is_default_branch}}
type=ref,event=branch,prefix=${{ matrix.php }}-apache-
type=ref,event=tag,prefix=${{ matrix.php }}-apache-
type=ref,event=pr,prefix=${{ matrix.php }}-apache-pr-
- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
context: .
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: TAG=${{ matrix.tag }}
- name: Setup to EC-CUBE
env:
APP_ENV: ${{ matrix.app_env }}
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
REGISTRY: ${{ env.REGISTRY }}
IMAGE_NAME: ${{ env.IMAGE_NAME }}
TAG: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
run: |
docker compose -f docker-compose.yml -f docker-compose.pgsql.yml up -d --wait
sed -i 's!APP_ENV: "dev"!APP_ENV: "prod"!g' docker-compose.yml
docker compose -f docker-compose.yml -f docker-compose.pgsql.yml up -d --wait
- name: setup-chromedriver
uses: nanasess/setup-chromedriver@master
- name: Run chromedriver
run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
echo ">>> Started chrome-driver"
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
- name: Codeception
env:
APP_ENV: ${{ matrix.app_env }}
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
MAILER_URL: 'smtp://127.0.0.1:1025'
GROUP: ${{ matrix.group }}
SYMFONY_DEPRECATIONS_HELPER: weak
run: |
echo "APP_ENV=${APP_ENV}" > .env
vendor/bin/codecept -vvv run acceptance --env chrome,github_action_docker -g ${GROUP}
## see https://docs.github.com/ja/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#publishing-a-package-using-an-action
- name: Push Docker image
uses: docker/build-push-action@v3
if: success()
with:
context: .
push: true
# platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: TAG=${{ matrix.tag }}
- name: Upload evidence
if: failure()
uses: actions/upload-artifact@v2
with:
name: codeception-${{ matrix.group }}-evidence
path: codeception/_output/
- name: Upload logs
if: failure()
uses: actions/upload-artifact@v2
with:
name: codeception-${{ matrix.group }}-logs
path: var/log/