You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const message = `Deployment has finished 👁️👄👁️ Your app is available [here](https://${{ github.event.pull_request.base.repo.name }}-PR-${{ github.event.number }}.cleverapps.io)`;
Copy file name to clipboardExpand all lines: README.md
+63-41Lines changed: 63 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,46 @@ The action will consider both branches on the same repository, and pull requests
15
15
- An [organisation](https://developers.clever-cloud.com/doc/account/administrate-organization/) in Clever Cloud
16
16
-[Clever Cloud CLI](https://developers.clever-cloud.com/doc/cli/getting_started/) installed in your machine to inject your tokens
17
17
18
+
### Mandatory configuration
19
+
20
+
Add the following secrets to your repository, in **Settings > Secrets and variables**:
21
+
22
+
-`CLEVER_SECRET` and `CLEVER_TOKEN`: find them in your `clever-tools.json` after installing the CLI (example path on Mac: `~/.config/clever-cloud/clever-tools.json`)
23
+
-`ORGA_ID`: the organisation in which your app is created
24
+
25
+
For better security, we advise generating a specific `CLEVER_SECRET` and `CLEVER_TOKEN` for GitHub Actions. Follow these steps to do so:
26
+
27
+
1. Create a new user with a new email adress on Clever Cloud
28
+
2. Create a specific organization for deploying review apps
29
+
3. From your terminal, run `clever logout` and `clever login` right after
30
+
4. Log into the Console with your new user credetials
31
+
5. Get the generated `CLEVER_SECRET` and `CLEVER_TOKEN` and inject it into your repository secrets
32
+
33
+
Run `clever login` again and connect from your main account to set your personal tokens. Your GitHub Acction user's tokens won't be revoked and will be used only from GitHub.
34
+
18
35
## How to Use this Action
19
36
20
-
Place this script in your repository in `.github/workflows/` and modify the following values:
37
+
1. In your `.github/workflow/review-app.yml`, define the event trigger for running the action:
21
38
22
-
-`<type>` for the type of app
23
-
-`region` for where you want the app to be deployed
24
-
-`<VARIABLE_NAME>` and `variable_value` for your environment variables
39
+
```yaml
40
+
on:
41
+
pull_request_target:
42
+
types: [opened, closed, synchronize, reopened]
43
+
branches: [ main ]
44
+
```
45
+
46
+
2. Then, define the mandatory input:
47
+
48
+
```yaml
49
+
- name: Create review app
50
+
uses: CleverCloud/clever-cloud-review-app@latest
51
+
env:
52
+
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
53
+
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
54
+
ORGA_ID: ${{ secrets.ORGA_ID }}
55
+
with:
56
+
type: '<type-of-app>'
57
+
```
25
58
26
59
### Values for `--type`
27
60
@@ -43,6 +76,32 @@ Place this script in your repository in `.github/workflows/` and modify the foll
43
76
- `static-apache`: for static (HTML only) websites
44
77
- `war`: for applications deployed as war files
45
78
79
+
### Inject secrets and variables
80
+
81
+
To inject your app secrets and environment variables on Clever Cloud, add them to your GitHub repository in **Settings > Secrets and variables**, then add them with an `GH_` prefix in your workflow file. Finally, enable the injection with `set-env: true`:
82
+
83
+
```yaml
84
+
name: Create review app
85
+
uses: CleverCloud/clever-cloud-review-app@latest
86
+
env:
87
+
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
88
+
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
89
+
ORGA_ID: ${{ secrets.ORGA_ID }}
90
+
GH_CC_RUN_SUCCEEDED_HOOK: ${{ secrets. CC_RUN_SUCCEEDED_HOOK }} # This envrironment variable will be set on Clever Cloud
91
+
with:
92
+
type: '<type-of-app>'
93
+
set-env: true # Enables the command to set en vars on Clever Cloud
94
+
```
95
+
96
+
## Options
97
+
98
+
You can override default options by defining `region`, `domain`, `name`, and `alias`. Default values are:
@@ -54,40 +113,3 @@ Place this script in your repository in `.github/workflows/` and modify the foll
54
113
- `sgp`(Singapore, OVHcloud)
55
114
- `syd`(Sydney, OVHcloud)
56
115
- `wsw`(Warsaw, OVHcloud)
57
-
58
-
## Secrets You'll Need
59
-
60
-
-`CLEVER_SECRET` and `CLEVER_TOKEN`: find them in your `clever-tools.json` after installing the CLI (example path on Mac: `~/.config/clever-cloud/clever-tools.json`)
61
-
-`ORGA_ID`: the organisation in which your app is created
62
-
63
-
For better security, we advise generating a specific `CLEVER_SECRET` and `CLEVER_TOKEN` for GitHub Actions. Follow these steps to do so:
64
-
65
-
1. Create a new user with a new email adress on Clever Cloud
66
-
2. Create a specific organization for deploying review apps
67
-
3. From your terminal, run `clever logout` and `clever login` right after
68
-
4. Log into the Console with your new user credetials
69
-
5. Get the generated `CLEVER_SECRET` and `CLEVER_TOKEN` and inject it into your repository secrets
70
-
71
-
Run `clever login` again and connect from your main account to set your personal tokens. Your GitHub Acction user's tokens won't be revoked and will be used only from GitHub.
72
-
73
-
## Inject App Secrets
74
-
75
-
You can pass more secrets in your app by setting them in your GitHub repository and listing them in `env` and adding them like this : `<A_SECRET>: ${{ secrets.<A_SECRET> }}`.
76
-
77
-
Then when injecting environment variables in `Create and deploy app` step, add `clever env set <A_SECRET> "$<A_SECRET>"`.
78
-
79
-
For better security, follow this syntax and store the secrets in-memory for each step, to avoid exploits and leaks, instead ouf sourcing them directly in a shell script.
const message = `Deployment has finished 👁️👄👁️ Your app is available [here](https://${{ github.event.pull_request.base.repo.name }}-PR-${{ github.event.number }}.cleverapps.io)`;
const message = `🚀 Your app has been updated and is available [here](https://${{ github.event.pull_request.base.repo.name }}-PR-${{ github.event.number }}.cleverapps.io)`;
109
-
github.rest.issues.createComment({
110
-
owner: context.repo.owner,
111
-
repo: context.repo.repo,
112
-
issue_number: issue_number,
113
-
body: message
114
-
});
115
-
env:
116
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117
-
118
-
# Delete review app when the PR is closed (merged or not)
0 commit comments