-
-
Notifications
You must be signed in to change notification settings - Fork 1
171 lines (150 loc) · 5.51 KB
/
main.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Main
on:
push:
branches:
- 'master'
- 'support/*'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
mariadb_tag: [
latest
]
wordpress_tag: [
5.9.3,
latest
]
node_tag: [
14
]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Docker
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.mariadb_tag }}-${{ matrix.wordpress_tag }}-${{ matrix.node_tag }}-${{ hashFiles('**/Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.mariadb_tag }}-${{ matrix.wordpress_tag }}-${{ matrix.node_tag }}-
- name: Cache npm modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node_tag }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node_tag }}-
#https://stackoverflow.com/a/71334100/3929620
- name: Set environment variables
run: |
PLUGIN_VERSION=$(echo "${GITHUB_REF##*/}" | sed 's/^v//')
echo "PLUGIN_VERSION=$PLUGIN_VERSION" >> $GITHUB_ENV
IS_VALID_TAG=$([[ "${GITHUB_REF##*/}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo true || echo '')
echo "IS_VALID_TAG=$IS_VALID_TAG" >> $GITHUB_ENV
echo "IS_LAST_JOB=$([ $(expr ${{ strategy.job-index }} + 1) = ${{ strategy.job-total }} ] && echo true)" >> $GITHUB_ENV
- name: Print environment variables
run: |
echo "PLUGIN_VERSION=${{ env.PLUGIN_VERSION }}"
echo "IS_VALID_TAG=${{ env.IS_VALID_TAG }}"
echo "IS_LAST_JOB=${{ env.IS_LAST_JOB }}"
- name: Create .env file
run: cp .env.dist .env
# method #1
- name: Install mkcert
run: |
sudo apt-get update && sudo apt-get install libnss3-tools
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
# method #2
#- name: Generate self-signed CA
# uses: kofemann/[email protected]
# with:
# hostcert: 'server.crt'
# hostkey: 'server.key'
# cachain: 'ca-chain.pem'
#- name: Move certificates
# run: |
# mkdir -p tmp/certs
# mv server.crt server.key ca-chain.pem tmp/certs/
- name: Run Makefile 'all' task
run: |
make \
MARIADB_TAG=$MARIADB_TAG \
WORDPRESS_TAG=$WORDPRESS_TAG \
NODE_TAG=$NODE_TAG \
PLUGIN_NAME=${{ github.event.repository.name }} \
PLUGIN_VERSION=${{ env.PLUGIN_VERSION }}
#https://cardinalby.github.io/blog/post/github-actions/implementing-deferred-steps/
# method #1
#- name: Wait for WordPress setup to complete
# run: |
# timeout=300
# while [ $timeout -gt 0 ]; do
# docker compose exec wordpress test -f /bitnami/wordpress/wp-config.php && break
# echo "Waiting for wp-config.php ($timeout seconds left)..."
# sleep 5
# timeout=$((timeout - 5))
# done
# [ $timeout -gt 0 ] || { echo "Error: Timeout reached, wp-config.php not found"; exit 1; }
# method #2
- name: Wait for WordPress setup to complete
run: ./build/docker/logs-catcher.sh wordpress "WordPress setup finished" 180
- name: Run Makefile 'install' task
run: |
make install \
MARIADB_TAG=$MARIADB_TAG \
WORDPRESS_TAG=$WORDPRESS_TAG \
NODE_TAG=$NODE_TAG \
PLUGIN_NAME=${{ github.event.repository.name }} \
PLUGIN_VERSION=${{ env.PLUGIN_VERSION }} \
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
- name: Run Makefile 'test' task
run: |
make test \
PLUGIN_NAME=${{ github.event.repository.name }} \
PLUGIN_VERSION=${{ env.PLUGIN_VERSION }}
#https://github.com/orgs/community/discussions/25641#discussioncomment-3248571
- name: Run Makefile 'deploy' task
if: |
github.ref_type == 'tag'
&& env.IS_VALID_TAG
&& env.IS_LAST_JOB
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
run: |
make deploy \
MODE=production \
MARIADB_TAG=$MARIADB_TAG \
WORDPRESS_TAG=$WORDPRESS_TAG \
NODE_TAG=$NODE_TAG \
PLUGIN_NAME=${{ github.event.repository.name }} \
PLUGIN_VERSION=${{ env.PLUGIN_VERSION }} \
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
- name: Create release
if: |
github.ref_type == 'tag'
&& env.IS_VALID_TAG
&& env.IS_LAST_JOB
uses: softprops/action-gh-release@v2
with:
# https://github.com/softprops/action-gh-release
# Note that if you intend to run workflows on the release event (on: { release: { types: [published] } }),
# you need to use a personal access token for this action, as the default secrets.GITHUB_TOKEN does not trigger another workflow.
# See: https://github.com/actions/create-release/issues/71
token: ${{ secrets.PRIVATE_GITHUB_TOKEN }}
files: dist/${{ github.event.repository.name }}.zip
generate_release_notes: true
- name: Run Makefile 'down' task
run: make down