-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (151 loc) · 6.12 KB
/
deploy.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
172
name: Deploy via ftp
on:
push:
branches: main
workflow_dispatch:
concurrency:
group: build-deploy
jobs:
deploy:
name: Deploy service to FTP
runs-on: ubuntu-latest
outputs:
semVer: ${{ steps.gitversion.outputs.semVer }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v2
with:
versionSpec: "5.x"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v2
with:
useConfigFile: true
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Install dependencies
uses: "php-actions/composer@v6"
with:
php_extensions: sockets
dev: no
progress: yes
working_dir: "./Src/"
- name: Create .htaccess secrets file
run: |
cd Src
mkdir -p secrets
cd secrets
echo "Deny from all" >> .htaccess
- name: Generate AppVeyor secrets file
run: |
cd Src
mkdir -p secrets
cd secrets
echo "<?php" >> appVeyor.secrets.php
echo "\$appVeyorKey = \"${{ secrets.APPVEYOR_KEY }}\";" >> appVeyor.secrets.php
- name: Generate Codacy secrets file
run: |
cd Src
mkdir -p secrets
cd secrets
echo "<?php" >> codacy.secrets.php
echo "\$codacyApiToken = \"${{ secrets.CODACY_API_TOKEN }}\";" >> codacy.secrets.php
- name: Generate Codecov secrets file
run: |
cd Src
mkdir -p secrets
cd secrets
echo "<?php" >> codecov.secrets.php
echo "\$codecovApiToken = \"${{ secrets.CODECOV_API_TOKEN }}\";" >> codecov.secrets.php
- name: Generate GitHub App secrets file
run: |
cd Src
mkdir -p secrets
cd secrets
echo "<?php" >> gitHubApp.secrets.php
echo "\$gitHubUserToken = \"${{ secrets.USER_TOKEN }}\";" >> gitHubApp.secrets.php
echo "\$gitHubAppId = \"${{ secrets.APP_ID }}\";" >> gitHubApp.secrets.php
echo "\$gitHubAppPrivateKey = \"${{ secrets.APP_PRIVATE_KEY}}\";" >> gitHubApp.secrets.php
echo "\$gitHubWebhookEndpoint = \"${{ secrets.WEBHOOK_ENDPOINT }}\";" >> gitHubApp.secrets.php
echo "\$gitHubWebhookSignature = \"${{ secrets.WEBHOOK_SIGNATURE }}\";" >> gitHubApp.secrets.php
- name: Generate HealthChecksIo secrets file
run: |
cd Src
mkdir -p secrets
cd secrets
echo "<?php" >> healthChecksIo.secrets.php
echo "\$healthChecksIoBranches = \"${{ secrets.HEALTHCHECKSIO_BRANCHES }}\";" >> healthChecksIo.secrets.php
echo "\$healthChecksIoIssues = \"${{ secrets.HEALTHCHECKSIO_ISSUES }}\";" >> healthChecksIo.secrets.php
echo "\$healthChecksIoComments = \"${{ secrets.HEALTHCHECKSIO_COMMENTS }}\";" >> healthChecksIo.secrets.php
echo "\$healthChecksIoPushes = \"${{ secrets.HEALTHCHECKSIO_PUSHES }}\";" >> healthChecksIo.secrets.php
echo "\$healthChecksIoPullRequests = \"${{ secrets.HEALTHCHECKSIO_PULL_REQUESTS }}\";" >> healthChecksIo.secrets.php
echo "\$healthChecksIoRepositories = \"${{ secrets.HEALTHCHECKSIO_REPOSITORIES }}\";" >> healthChecksIo.secrets.php
echo "\$healthChecksIoSignature = \"${{ secrets.HEALTHCHECKSIO_SIGNATURE }}\";" >> healthChecksIo.secrets.php
- name: Create Logger secrets file
run: |
cd Src
mkdir -p secrets
cd secrets
echo "<?php" >> logger.secrets.php
echo "\$loggerUrl = \"${{ secrets.LOGGER_URL }}\";" >> logger.secrets.php
echo "\$loggerApiKey = \"${{ secrets.LOGGER_APIKEY }}\";" >> logger.secrets.php
echo "\$loggerApiToken = \"${{ secrets.LOGGER_APITOKEN }}\";" >> logger.secrets.php
- name: Create MySQL secrets file
run: |
cd Src
mkdir -p secrets
cd secrets
echo "<?php" >> mySql.secrets.php
echo "\$mySqlHost = \"127.0.0.1\";" >> mySql.secrets.php
echo "\$mySqlUser = \"${{ secrets.MYSQL_USER }}\";" >> mySql.secrets.php
echo "\$mySqlPassword = \"${{ secrets.MYSQL_PASSWORD }}\";" >> mySql.secrets.php
echo "\$mySqlDatabase = \"${{ secrets.MYSQL_DATABASE }}\";" >> mySql.secrets.php
- name: Create RabbitMQ secrets file
run: |
SECRETS_CONTEXT='${{ toJson(secrets) }}'
cd Src
mkdir -p secrets
cd secrets
echo "<?php" >> rabbitMq.secrets.php
rabbitmq_values=$(echo "$SECRETS_CONTEXT" | jq -S '.' | jq -r 'to_entries | map(select(.key | startswith("RABBITMQ_"))) | .[].value')
for value in $rabbitmq_values; do
value_final=$(echo $value | sed 's/\\n/ /g')
echo "\$rabbitMqConnectionStrings[] = \"$value_final\";" >> rabbitMq.secrets.php
done
- name: Create version file for API
run: |
cd Src
echo ${{ env.fullSemVer }} > version.txt
- name: Upload service
uses: sebastianpopp/ftp-action@releases/v2
with:
host: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
localDir: "Src"
remoteDir: "/"
create_release:
name: Create release
needs: deploy
env:
SEMVER: ${{ needs.deploy.outputs.semVer }}
runs-on: ubuntu-latest
steps:
- name: Create Release
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: false
skipIfReleaseExists: true
draft: false
makeLatest: true
tag: v${{ env.SEMVER }}
name: Release v${{ env.SEMVER }}
generateReleaseNotes: true
body: Release ${{ env.SEMVER }} of ${{ github.event.repository.name }}