-
Notifications
You must be signed in to change notification settings - Fork 3
151 lines (135 loc) · 6 KB
/
main.yml
File metadata and controls
151 lines (135 loc) · 6 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
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
name: demyx/wordpress
on:
push:
branches:
- master
schedule:
- cron: '0 0 * * 6'
jobs:
master:
runs-on: ubuntu-latest
env:
DEMYX_REPOSITORY: wordpress
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login
uses: docker/login-action@v1
with:
username: demyx
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build
run: |
docker pull alpine
docker pull demyx/nginx
docker pull demyx/mariadb
docker build -t demyx/${{ env.DEMYX_REPOSITORY }} tag-latest
docker build -t demyx/${{ env.DEMYX_REPOSITORY }}:bedrock tag-bedrock
#docker build -t demyx/${{ env.DEMYX_REPOSITORY }}:cli tag-cli
#docker build -t demyx/${{ env.DEMYX_REPOSITORY }}:7.4 tag-7.4
- name: Test
id: test
shell: 'script -q -e -c "bash {0}"'
run: |
docker network create demyx
# tag-latest test
docker run -d \
--name=demyx_db \
--network=demyx \
-e DEMYX_DATABASE=demyx \
-e DEMYX_USERNAME=demyx \
-e DEMYX_PASSWORD=demyx \
-e DEMYX_ROOT_PASSWORD=demyx \
demyx/mariadb
sleep 10
docker run -d \
--name=${{ env.DEMYX_REPOSITORY }} \
--network=demyx \
-v ${{ env.DEMYX_REPOSITORY }}:/demyx \
-e DEMYX_DB_HOST=demyx_db \
-e DEMYX_DB_NAME=demyx \
-e DEMYX_DB_USER=demyx \
-e DEMYX_DB_PASSWORD=demyx \
-e DEMYX_DOMAIN=localhost \
demyx/${{ env.DEMYX_REPOSITORY }}
docker run -d \
--name=demyx_nx \
--network=demyx \
-v ${{ env.DEMYX_REPOSITORY }}:/demyx \
-e DEMYX_WORDPRESS=true \
-e DEMYX_WORDPRESS_CONTAINER=${{ env.DEMYX_REPOSITORY }} \
-e DEMYX_DOMAIN=localhost \
demyx/nginx
# tag-bedrock test
docker run -d \
--name=demyx_db_bedrock \
--network=demyx \
-e DEMYX_DATABASE=demyx \
-e DEMYX_USERNAME=demyx \
-e DEMYX_PASSWORD=demyx \
-e DEMYX_ROOT_PASSWORD=demyx \
demyx/mariadb
#sleep 10
# TODO: Fix this later
#docker run -d \
# --name=${{ env.DEMYX_REPOSITORY }}_bedrock \
# --network=demyx \
# -v ${{ env.DEMYX_REPOSITORY }}_bedrock:/demyx \
# -e DEMYX_DB_HOST=demyx_db_bedrock \
# -e DEMYX_DB_NAME=demyx \
# -e DEMYX_DB_USER=demyx \
# -e DEMYX_DB_PASSWORD=demyx \
# -e DEMYX_DOMAIN=localhost \
# demyx/${{ env.DEMYX_REPOSITORY }}:bedrock
#docker run -d \
# --name=demyx_nx_bedrock \
# --network=demyx \
# -v ${{ env.DEMYX_REPOSITORY }}_bedrock:/demyx \
# -e DEMYX_BEDROCK=true \
# -e DEMYX_WORDPRESS=true \
# -e DEMYX_WORDPRESS_CONTAINER=${{ env.DEMYX_REPOSITORY }}_bedrock \
# -e DEMYX_DOMAIN=localhost \
# demyx/nginx
sleep 10
DEMYX_TEST="$(docker exec demyx_nx sh -c "wget -qO- http://localhost" 2>&1)"
DEMYX_TEST_BEDROCK="$(docker exec demyx_nx_bedrock sh -c "wget -qO- http://localhost" 2>&1)"
#if [[ "$DEMYX_TEST" == *"Hello world"* && "$DEMYX_TEST_BEDROCK" == *"Hello world"* ]]; then
if [[ "$DEMYX_TEST" == *"Hello world"* ]]; then
echo "Tests passed."
else
exit 1
fi
- name: Version
run: |
DEMYX_WORDPRESS_ALPINE_VERSION="$(docker exec ${{ env.DEMYX_REPOSITORY }} cat /etc/os-release | grep VERSION_ID | cut -c 12-)"
DEMYX_WORDPRESS_VERSION="$(docker exec ${{ env.DEMYX_REPOSITORY }} wp core version)"
DEMYX_WORDPRESS_BEDROCK_VERSION="$(curl -sL https://api.github.com/repos/roots/bedrock/releases/latest | jq -r '.tag_name')"
DEMYX_WORDPRESS_CLI_VERSION="$(docker exec ${{ env.DEMYX_REPOSITORY }} --version | awk -F '[ ]' '{print $2}')"
DEMYX_WORDPRESS_PHP_VERSION="$(docker exec ${{ env.DEMYX_REPOSITORY }} php82 -v | grep cli | awk -F '[ ]' '{print $2}')"
DEMYX_WORDPRESS_PHP_LATEST_VERSION="$(docker exec ${{ env.DEMYX_REPOSITORY }} php -v | grep cli | awk -F '[ ]' '{print $2}')"
DEMYX_JQ="$(jq ".alpine = \"$DEMYX_WORDPRESS_ALPINE_VERSION\" | .wordpress = \"$DEMYX_WORDPRESS_VERSION\" | .bedrock = \"$DEMYX_WORDPRESS_BEDROCK_VERSION\" | .wp_cli = \"$DEMYX_WORDPRESS_CLI_VERSION\" | .php = \"$DEMYX_WORDPRESS_PHP_VERSION\" | .php81 = \"$DEMYX_WORDPRESS_PHP_LATEST_VERSION\"" version.json)"
# Update versions
echo "$DEMYX_JQ" > version.json
echo "DEMYX_WORDPRESS_ALPINE_VERSION=$DEMYX_WORDPRESS_ALPINE_VERSION
DEMYX_WORDPRESS_VERSION=$DEMYX_WORDPRESS_VERSION
DEMYX_WORDPRESS_BEDROCK_VERSION=$DEMYX_WORDPRESS_BEDROCK_VERSION
DEMYX_WORDPRESS_CLI_VERSION=$DEMYX_WORDPRESS_CLI_VERSION
DEMYX_WORDPRESS_PHP_VERSION=$DEMYX_WORDPRESS_PHP_VERSION
DEMYX_WORDPRESS_PHP_LATEST_VERSION=$DEMYX_WORDPRESS_PHP_LATEST_VERSION" > VERSION
- name: Push
run: |
# Not sure why this is being created?
[[ -f typescript ]] && rm -f typescript
DEMYX_CHECK_STATUS="$(git status)"
if [[ "$DEMYX_CHECK_STATUS" != *"nothing to commit"* ]]; then
git config --global user.name github-actions[bot]
git config --global user.email github-actions[bot]@users.noreply.github.com
git remote set-url origin https://demyxsh:${{ secrets.DEMYX_TOKEN }}@github.com/demyxsh/${{ env.DEMYX_REPOSITORY }}
git add .
git commit -m "Schedule Build #${{ github.run_id }}"
git push
fi
docker push demyx/${{ env.DEMYX_REPOSITORY }}
docker push demyx/${{ env.DEMYX_REPOSITORY }}:bedrock
#docker push demyx/${{ env.DEMYX_REPOSITORY }}:cli
#docker push demyx/${{ env.DEMYX_REPOSITORY }}:7.4