Skip to content

Commit 93a4994

Browse files
committed
Initial code
1 parent 4078e3e commit 93a4994

File tree

5 files changed

+255
-2
lines changed

5 files changed

+255
-2
lines changed

README.md

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,89 @@
1-
# install-impresscms-action
2-
GitHub action to install @ImpressCMS
1+
[![License](https://img.shields.io/github/license/impresscms-dev/install-impresscms-action.svg)](LICENSE)
2+
[![GitHub release](https://img.shields.io/github/release/impresscms-dev/install-impresscms-action.svg)](https://github.com/impresscms-dev/install-impresscms-action/releases)
3+
4+
# Install ImpressCMS
5+
6+
GitHub action to install [ImpressCMS](https://github.com/ImpressCMS/impresscms).
7+
8+
At current moment it works only with ImpressCMS versions that uses [Composer](https://getcomposer.org) and [Phoenix](https://github.com/lulco/phoenix).
9+
10+
## Usage
11+
12+
To use this action in your project, create workflow in your project similar to this code (Note: some parts and arguments
13+
needs to be altered):
14+
15+
```yaml
16+
name: Install ImpressCMS
17+
18+
on:
19+
push:
20+
21+
jobs:
22+
install:
23+
runs-on: ubuntu-latest
24+
25+
services:
26+
mysql:
27+
image: mysql:5.6
28+
env:
29+
MYSQL_ROOT_PASSWORD: icms
30+
MYSQL_DATABASE: icms
31+
ports:
32+
- 3306
33+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
34+
35+
steps:
36+
- name: Checkouting project code...
37+
uses: actions/checkout@v2
38+
with:
39+
repository: ImpressCMS/impresscms
40+
41+
- name: Installing ImpressCMS...
42+
uses: impresscms-dev/install-impresscms-action@v0.1
43+
with:
44+
database_name: icms
45+
database_user: root
46+
database_password: icms
47+
database_port: ${{ job.services.mysql.ports['3306'] }}
48+
```
49+
50+
## Arguments
51+
52+
This action supports such arguments (used in `with` keyword):
53+
54+
| Argument | Required | Default value | Description |
55+
|----------|----------|------------------------------|-------------------|
56+
| url | No | http://localhost | Site URL |
57+
| database_type | No | pdo.mysql | Database type |
58+
| database_name | No | icms | Database name |
59+
| database_host | No | 127.0.0.1 | Database host |
60+
| database_user | Yes | | Database user |
61+
| database_password | No | | Database password |
62+
| database_charset | No | utf8 | Charset used for database |
63+
| database_collation | No | utf8_general_ci | Collation used for database |
64+
| database_prefix | No | *icms_{run_id}_{run_attemnpt}* | Prefix for each ImpressCMS database table |
65+
| database_port | No | 3306 | Port that is used for database connection |
66+
| admin_name | No | icms | Administrator name |
67+
| admin_login | No | icms | Administrator login string |
68+
| admin_pass | No | icms | Administrator password |
69+
| admin_email | No | noreply@impresscms.dev | Administrator email |
70+
| language | No | english | Installation language |
71+
| app_key | No | | Application key. If not specified and your ImpressCMS version supports it, it will be generated automatically |
72+
73+
## Outputs
74+
75+
This action outputs following data, that can be used in other actions:
76+
77+
| Name | Type | Description |
78+
|------|---------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
79+
| app_key | string | Generated application key |
80+
| uses_composer | boolean | Returns if current ImpressCMS version uses [Composer](https://getcomposer.org) for package management |
81+
| uses_phoenix | boolean | Returns if current ImpressCMS version uses [Phoenix](https://github.com/lulco/phoenix) for migrations |
82+
83+
## How to contribute?
84+
85+
If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how
86+
this works, try [interactive GitHub tutorial](https://skills.github.com).
87+
88+
If you found any bug or have some questions,
89+
use [issues tab](https://github.com/impresscms-dev/install-impresscms-action/issues) and write there your questions.

action.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: 'Install ImpressCMS'
2+
description: 'GitHub action to install ImpressCMS'
3+
4+
# https://actions-cool.github.io/github-action-branding/
5+
branding:
6+
icon: cpu
7+
color: 'yellow'
8+
9+
inputs:
10+
url:
11+
description: "Site URL"
12+
default: http://localhost
13+
required: false
14+
database_type:
15+
description: "Database type"
16+
default: pdo.mysql
17+
required: false
18+
database_host:
19+
description: "Database host"
20+
default: 127.0.0.1
21+
required: false
22+
database_user:
23+
description: "Database user"
24+
required: true
25+
database_password:
26+
description: "Database password"
27+
default: ""
28+
required: false
29+
database_name:
30+
description: "Database name"
31+
default: icms
32+
required: false
33+
database_charset:
34+
description: "Charset used for database"
35+
default: utf8
36+
required: false
37+
database_collation:
38+
description: "Collation used for database"
39+
default: utf8_general_ci
40+
required: false
41+
database_prefix:
42+
description: "Prefix for each ImpressCMS database table"
43+
default: icms_${{ github.run_id }}_${{ github.run_attempt }}
44+
required: false
45+
database_port:
46+
description: "Port that is used for database connection"
47+
default: "3306"
48+
required: false
49+
admin_name:
50+
description: "Administrator name"
51+
default: icms
52+
required: false
53+
admin_login:
54+
description: "Administrator login string"
55+
default: icms
56+
required: false
57+
admin_pass:
58+
description: "Administrator password"
59+
default: icms
60+
required: false
61+
admin_email:
62+
description: "Administrator email"
63+
default: noreply@impresscms.dev
64+
required: false
65+
language:
66+
description: "Installation language"
67+
default: english
68+
required: false
69+
app_key:
70+
description: "Application key. If not specified and your ImpressCMS version supports it, it will be generated automatically"
71+
default: ""
72+
required: false
73+
74+
outputs:
75+
app_key:
76+
description: Generated application key
77+
value: ${{ steps.checks2.outputs.app_key }}
78+
uses_composer:
79+
description: Returns if current ImpressCMS version uses Composer for package management
80+
value: ${{ steps.checks1.outputs.uses_composer }}
81+
uses_phoenix:
82+
description: Returns if current ImpressCMS version uses Phoenix for migrations
83+
value: ${{ steps.checks2.outputs.uses_phoenix }}
84+
85+
runs:
86+
using: 'composite'
87+
steps:
88+
- name: Doing some nessary checks (part I)
89+
id: checks1
90+
run: |
91+
bash ${{ github.action_path }}/bin/uses-composer.sh
92+
shell: bash
93+
94+
- name: Failing because of no composer support
95+
run: |
96+
echo 'ERROR: Currently only ImpressCMS versions that has composer support are supported for this action'
97+
exit 1
98+
shell: bash
99+
if: steps.checks1.outputs.uses_composer == 'false'
100+
101+
- name: Install Composer dependencies (with dev)
102+
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
103+
shell: bash
104+
105+
- name: Doing some nessary checks (part II)
106+
id: checks2
107+
run: |
108+
bash ${{ github.action_path }}/bin/app-key.sh "${{ inputs.app_key }}"
109+
bash ${{ github.action_path }}/bin/uses-phoenix.sh
110+
shell: bash
111+
112+
- name: Failing because of no phoenix support
113+
run: |
114+
echo 'ERROR: Currently only ImpressCMS versions that has phoenix support are supported for this action'
115+
exit 1
116+
shell: bash
117+
if: steps.checks1.outputs.uses_phoenix == 'false'
118+
119+
- name: Chmoding folders...
120+
run: chmod -R 0777 ./storage ./modules ./themes ./uploads
121+
shell: bash
122+
123+
- name: Installing ImpressCMS
124+
env:
125+
URL: ${{ inputs.url }}
126+
DB_TYPE: ${{ inputs.database_type }}
127+
DB_HOST: ${{ inputs.database_host }}
128+
DB_USER: ${{ inputs.database_user }}
129+
DB_PASS: ${{ inputs.database_password }}
130+
DB_PCONNECT: "0"
131+
DB_NAME: ${{ inputs.database_name }}
132+
DB_CHARSET: ${{ inputs.database_charset }}
133+
DB_COLLATION: ${{ inputs.database_collation }}
134+
DB_PREFIX: ${{ inputs.database_prefix }}
135+
DB_PORT: ${{ inputs.database_port }}
136+
INSTALL_ADMIN_PASS: ${{ inputs.admin_name }}
137+
INSTALL_ADMIN_LOGIN: ${{ inputs.admin_login }}
138+
INSTALL_ADMIN_NAME: ${{ inputs.admin_pass }}
139+
INSTALL_ADMIN_EMAIL: ${{ inputs.admin_email }}
140+
INSTALL_LANGUAGE: ${{ inputs.language }}
141+
APP_KEY: ${{ steps.checks2.outputs.app_key }}
142+
run: ./bin/phoenix migrate -vvv
143+
shell: bash

bin/app-key.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
CURRENT_APP_KEY="$1"
4+
5+
if [ "$CURRENT_APP_KEY" == "" ]; then
6+
echo "::set-output name=app_key::$(php ./bin/console generate:app:key || echo '')"
7+
else
8+
echo "::set-output name=app_key::$CURRENT_APP_KEY"
9+
fi;

bin/uses-composer.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -f "composer.json" ]; then
4+
echo "::set-output name=uses_composer::true";
5+
else
6+
echo "::set-output name=uses_composer::false";
7+
fi;

bin/uses-phoenix.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -f "./bin/phoenix" ] || [ -f "./bin/phoenix.bat" ]; then
4+
echo "::set-output name=uses_phoenix::1";
5+
else
6+
echo "::set-output name=uses_phoenix::0";
7+
fi;

0 commit comments

Comments
 (0)