Skip to content

Commit c1c2ba2

Browse files
Add IONOS Deploy Now workflow
1 parent 8e53b63 commit c1c2ba2

File tree

6 files changed

+341
-0
lines changed

6 files changed

+341
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
APP_DEBUG=0
2+
APP_ENV=prod
3+
APP_SECRET=
4+
5+
DATABASE_URL="mysql://$IONOS_DB_USERNAME:${IONOS_DB_PASSWORD.urlEncoded()}@$IONOS_DB_HOST:3306/$IONOS_DB_NAME?serverVersion=mariadb-10.5&charset=utf8mb4"
6+
MAILER_DSN="smtp://$IONOS_MAIL_USERNAME:${IONOS_MAIL_PASSWORD.urlEncoded()}@$IONOS_MAIL_HOST:$IONOS_MAIL_PORT"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# enable gzip compressing for the following mime-types
2+
<IfModule mod_deflate.c>
3+
AddOutputFilterByType DEFLATE text/plain
4+
AddOutputFilterByType DEFLATE text/html
5+
AddOutputFilterByType DEFLATE text/xml
6+
AddOutputFilterByType DEFLATE text/shtml
7+
AddOutputFilterByType DEFLATE text/css
8+
AddOutputFilterByType DEFLATE application/xml
9+
AddOutputFilterByType DEFLATE application/xhtml+xml
10+
AddOutputFilterByType DEFLATE application/rss+xml
11+
AddOutputFilterByType DEFLATE application/javascript
12+
AddOutputFilterByType DEFLATE application/x-javascript
13+
</IfModule>
14+
15+
### IMPORTANT ###
16+
### Because we can't change the webroot folder to a subfolder of the document root, we need this rewrite rules ###
17+
18+
RewriteEngine on
19+
20+
# serve existing files in the /public folder as if they were in /
21+
RewriteCond %{REQUEST_URI} !public/
22+
RewriteRule (.*) /public/$1 [L]
23+
24+
# route everything else to /public/index.php
25+
RewriteRule ^ /public/index.php [L]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
version: 1.0
2+
3+
deploy:
4+
# configuration part, which is taken at the FIRST deployment of each branch
5+
bootstrap:
6+
# folders that are not copied to IONOS webspace
7+
excludes:
8+
- tests
9+
- node_modules
10+
- DOCKER_ENV
11+
- docker_tag
12+
- output.log
13+
# commands that are executed at the real webspace NOT at build servers AFTER copying new files
14+
post-deployment-remote-commands:
15+
- php bin/create-app-secret
16+
- find $(pwd) -type f -not -path "$(pwd)/logs/*" -exec chmod 664 {} \;
17+
- find $(pwd) -type d -not -name "logs" -exec chmod 775 {} \;
18+
- mkdir -p var && chmod -R o+w var
19+
- APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear
20+
- php bin/console assets:install
21+
- APP_ENV=prod APP_DEBUG=0 php bin/console cache:warmup
22+
23+
# configuration part, which is taken at ALL FURTHER deployments of this branch
24+
recurring:
25+
# folders that are not copied to IONOS webspace
26+
excludes:
27+
- tests
28+
- node_modules
29+
- DOCKER_ENV
30+
- docker_tag
31+
- output.log
32+
- var
33+
# commands that are executed at the real webspace NOT at build servers BEFORE copying new files
34+
pre-deployment-remote-commands:
35+
- echo "here you could enter maintenance mode..."
36+
# commands that are executed at the real webspace NOT at build servers AFTER copying new files
37+
post-deployment-remote-commands:
38+
- php bin/create-app-secret
39+
- find $(pwd) -type f -not -path "$(pwd)/logs/*" -exec chmod 664 {} \;
40+
- find $(pwd) -type d -not -name "logs" -exec chmod 775 {} \;
41+
- chmod -R o+w var
42+
- APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear
43+
- php bin/console assets:install
44+
- APP_ENV=prod APP_DEBUG=0 php bin/console cache:warmup
45+
46+
# uncomment the following lines to configure cron jobs
47+
#runtime:
48+
# cron-jobs:
49+
# - command: my-cron-job-command # the deployment is located at $HOME/htdocs/ to execute a deployed script just prefix it accordingly
50+
# schedule: 0 5 * * * # run every day at 5:00
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Please do not edit this file.
2+
# More information under https://docs.ionos.space/docs/github-actions-customization/
3+
# version: 2022-07-21
4+
5+
name: "Deploy Now: Deploy to IONOS"
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
required: true
12+
type: string
13+
project-id:
14+
required: true
15+
type: string
16+
branch-id:
17+
required: true
18+
type: string
19+
deployment-ids:
20+
require: true
21+
type: string
22+
push:
23+
path:
24+
- ./.github/workflows/deploy-to-ionos.yaml
25+
26+
concurrency: ${{ github.ref }}
27+
28+
jobs:
29+
deploy-to-ionos:
30+
if: ${{ github.event_name == 'workflow_dispatch' }}
31+
runs-on: ubuntu-latest
32+
permissions:
33+
actions: read
34+
strategy:
35+
matrix:
36+
deployment-id: ${{ fromJson(inputs.deployment-ids) }}
37+
steps:
38+
- name: Update deployment status
39+
uses: ionos-deploy-now/project-action@v1
40+
with:
41+
api-key: ${{ secrets.IONOS_API_KEY }}
42+
service-host: api-eu.ionos.space
43+
project-id: ${{ inputs.project-id }}
44+
branch-id: ${{ inputs.branch-id }}
45+
deployment-id: ${{ matrix.deployment-id }}
46+
action: update-status
47+
status: in_progress
48+
49+
- name: Retrieve stored deployment
50+
uses: ionos-deploy-now/artifact-action@v1
51+
with:
52+
api-key: ${{ secrets.IONOS_API_KEY }}
53+
service-host: api-eu.ionos.space
54+
project-id: ${{ inputs.project-id }}
55+
branch-id: ${{ inputs.branch-id }}
56+
version: ${{ inputs.version }}
57+
action: download
58+
59+
- name: Fetch deployment info
60+
uses: ionos-deploy-now/project-action@v1
61+
id: deployment
62+
with:
63+
api-key: ${{ secrets.IONOS_API_KEY }}
64+
service-host: api-eu.ionos.space
65+
project-id: ${{ inputs.project-id }}
66+
branch-id: ${{ inputs.branch-id }}
67+
deployment-id: ${{ matrix.deployment-id }}
68+
action: retrieve-info
69+
70+
- name: Render templates
71+
uses: ionos-deploy-now/template-renderer-action@v2
72+
id: template
73+
with:
74+
deployment-id: ${{ matrix.deployment-id }}
75+
data: "[${{ steps.deployment.outputs.template-variables }}, ${{ toJson(secrets) }}]"
76+
input-directory: deployment
77+
output-directory: deployment
78+
intermediate-data-file: deployment/.template-renderer-data
79+
80+
- name: Render real site-url to all files
81+
run: |
82+
for file in `grep -rl 'https://IONOS_DEPLOY_NOW_SITE_URL' .`; do
83+
sed -i $file -e 's|https://IONOS_DEPLOY_NOW_SITE_URL|${{ fromJson(steps.deployment.outputs.info).site-url }}|g'
84+
done
85+
86+
- name: Render SSH user secret name
87+
run: echo SSH_USERNAME_SECRET=IONOS_DEPLOYMENT_`echo ${{ matrix.deployment-id }} | tr '[:lower:]' '[:upper:]' | tr '-' '_'`_SSH_USERNAME >> $GITHUB_ENV
88+
89+
- name: Deploy to IONOS
90+
uses: ionos-deploy-now/deploy-to-ionos-action@v2
91+
with:
92+
api-key: ${{ secrets.IONOS_API_KEY }}
93+
service-host: api-eu.ionos.space
94+
project-id: ${{ inputs.project-id }}
95+
branch-id: ${{ inputs.branch-id }}
96+
deployment-id: ${{ matrix.deployment-id }}
97+
deployment-info: ${{ steps.deployment.outputs.info }}
98+
ssh-user: ${{ secrets[env.SSH_USERNAME_SECRET] }}
99+
ssh-key: ${{ secrets.IONOS_SSH_KEY }}
100+
101+
- name: Update deployment status
102+
if: ${{ always() }}
103+
uses: ionos-deploy-now/project-action@v1
104+
with:
105+
api-key: ${{ secrets.IONOS_API_KEY }}
106+
service-host: api-eu.ionos.space
107+
project-id: ${{ inputs.project-id }}
108+
branch-id: ${{ inputs.branch-id }}
109+
deployment-id: ${{ matrix.deployment-id }}
110+
action: update-status
111+
status: ${{ job.status }}
112+
113+
notify-deployment-finished:
114+
needs: deploy-to-ionos
115+
if: ${{ github.event_name == 'workflow_dispatch' && always() }}
116+
runs-on: ubuntu-latest
117+
steps:
118+
- name: Notify all deployments finished
119+
uses: ionos-deploy-now/project-action@v1
120+
with:
121+
api-key: ${{ secrets.IONOS_API_KEY }}
122+
service-host: api-eu.ionos.space
123+
project-id: ${{ inputs.project-id }}
124+
branch-id: ${{ inputs.branch-id }}
125+
action: set-deployments-finished
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# To better understand this file read this:
2+
# https://docs.ionos.space/docs/github-actions-customization/
3+
4+
name: "Deploy Now: Execute Build"
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
site-url:
10+
required: true
11+
type: string
12+
branch-id:
13+
required: true
14+
type: string
15+
16+
env:
17+
DEPLOYMENT_FOLDER: ./
18+
19+
jobs:
20+
# Please do not rename this job
21+
build-project:
22+
name: build symfony-starter-ionos-deploy
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
packages: write
27+
# if you add permissions here this needs to be done in the symfony-starter-ionos-deploy-orchestration.yaml as well
28+
steps:
29+
- name: checkout
30+
uses: actions/checkout@v3
31+
with:
32+
submodules: 'recursive'
33+
34+
- name: Render templates
35+
uses: ionos-deploy-now/template-renderer-action@v2
36+
id: template
37+
with:
38+
input-directory: .deploy-now/symfony-starter-ionos-deploy
39+
output-directory: ${{ env.DEPLOYMENT_FOLDER }}
40+
intermediate-data-file: ${{ env.DEPLOYMENT_FOLDER }}/.template-renderer-data
41+
42+
- name: Setup Node
43+
uses: actions/setup-node@v3
44+
with:
45+
node-version: v16.x
46+
47+
- name: Build Node assets
48+
env:
49+
CI: true
50+
SITE_URL: ${{ inputs.site-url }}
51+
run: |
52+
npm ci
53+
npm run build
54+
55+
- name: Setup composer
56+
uses: php-actions/composer@v6
57+
# uncomment the following lines if you want to add environment variables for this step
58+
# env:
59+
# MY_ENV_VAR: value-for-my-env-var
60+
# MY_SECRET_ENV_VAR: ${{ secrets.MY_SECRET }} # here you can find information how to create secrets: https://docs.github.com/en/actions/security-guides/encrypted-secrets
61+
with:
62+
php_version: '8.1.0'
63+
version: '2'
64+
args: --optimize-autoloader --no-dev
65+
66+
# Please do not touch the following action
67+
- name: Store deployment content
68+
uses: ionos-deploy-now/artifact-action@v1
69+
with:
70+
api-key: ${{ secrets.IONOS_API_KEY }}
71+
service-host: api-eu.ionos.space
72+
project-id: 4501b8a4-424d-42bb-bce7-ca2fec811baa
73+
branch-id: ${{ inputs.branch-id }}
74+
version: ${{ github.sha }}
75+
folder: ${{ env.DEPLOYMENT_FOLDER }}
76+
config-file: .deploy-now/symfony-starter-ionos-deploy/config.yaml
77+
action: upload
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Please do not edit this file.
2+
# Build steps can be customized in the symfony-starter-ionos-deploy-build.yaml.
3+
# More information under https://docs.ionos.space/docs/github-actions-customization/
4+
# version: 2022-07-21
5+
6+
name: "Deploy Now: Orchestration"
7+
run-name: "Deploy Now: Build symfony-starter-ionos-deploy · ${{ github.event.head_commit.message || format('Triggered by {0}', github.triggering_actor) }}"
8+
9+
on:
10+
- push
11+
- workflow_dispatch
12+
13+
jobs:
14+
retrieve-project:
15+
name: check readiness
16+
runs-on: ubuntu-latest
17+
outputs:
18+
deployment-enabled: ${{ fromJson(steps.project.outputs.info).deployment-enabled }}
19+
branch-id: ${{ fromJson(steps.project.outputs.info).branch-id }}
20+
steps:
21+
- name: Fetch project data
22+
uses: ionos-deploy-now/project-action@v1
23+
id: project
24+
with:
25+
api-key: ${{ secrets.IONOS_API_KEY }}
26+
service-host: api-eu.ionos.space
27+
project-id: 4501b8a4-424d-42bb-bce7-ca2fec811baa
28+
action: retrieve-info
29+
30+
31+
build:
32+
name: build
33+
needs: retrieve-project
34+
permissions:
35+
contents: read
36+
packages: write
37+
if: ${{ needs.retrieve-project.outputs.deployment-enabled == 'true' }}
38+
uses: ./.github/workflows/symfony-starter-ionos-deploy-build.yaml
39+
with:
40+
site-url: https://IONOS_DEPLOY_NOW_SITE_URL
41+
branch-id: ${{ needs.retrieve-project.outputs.branch-id }}
42+
secrets: inherit
43+
44+
deploy:
45+
name: trigger deployment
46+
needs:
47+
- retrieve-project
48+
- build
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Dispatch deployment(s)
52+
uses: ionos-deploy-now/project-action@v1
53+
with:
54+
api-key: ${{ secrets.IONOS_API_KEY }}
55+
service-host: api-eu.ionos.space
56+
project-id: 4501b8a4-424d-42bb-bce7-ca2fec811baa
57+
branch-id: ${{ needs.retrieve-project.outputs.branch-id }}
58+
action: dispatch-deployments

0 commit comments

Comments
 (0)