Unverified Commit a26e7cfe authored by GridexX's avatar GridexX
Browse files

feat: add clever_deploy job

parent 916575d6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
# Changelog
All notable changes to this job will be documented in this file.

## [0.1.0] - 2022-07-25
* Initial version
 No newline at end of file
+34 −0
Original line number Diff line number Diff line
## Objective

Deploy your static website on a Clever Cloud application.

## How to use it

1. On your computer, install the Clever Cli and login into your account by following the [documentation](https://www.clever-cloud.com/doc/getting-started/cli/) .
1. Retrieve your secret in the file `~/.config/clever-cloud` and set variables `CLEVER_TOKEN` and `CLEVER_SECRET` in the GitLab CI/CD variables section of your project.
1. Copy the job URL located in the `Install` part of the right panel and add it inside the `include` list of your `.gitlab-ci.yml` file (see the [quick setup](/use-the-hub/#quick-setup)). You can specify [a fixed version](#changelog) instead of `latest`.
1. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/use-the-hub/#jobs-customization)
1. Well done, your job is ready to work ! 😀

## Job details

* Job name: `clever_deploy`
* Docker image:
[`node:18-buster`](https://hub.docker.com/r/_/node)
* Default stage: `deploy`
* When: `always`

### Variables

| Name | Description | Default |
| ---- | ----------- | ------- |
| `CLEVER_BUILD_PATH` <img width=100/> | Path to folder which contains the static website files to publish <img width=175/>| `website_build` <img width=100/>|
| `CLEVER_APP` | Name of the application | `$CI_PROJECT_PATH_SLUG` |
| `CLEVER_TOKEN` | ⚠️ Mandatory variable. The clever token used for authentication. This variable should be specified in GitLab > CI/CD Settings. | ` ` |
| `CLEVER_SECRET` | ⚠️ Mandatory variable. The clever secret used for authentication. This variable should be specified in GitLab > CI/CD Settings. | ` ` |
| `CLEVER_PACKAGE_VERSION` | The version of the npm packages [clever-tools](https://gitlab.com/r2devops/hub/-/blob/latest/npmjs.com/package/clever-tools) | `2.9.1` |
| `IMAGE_TAG` | The default tag for the docker image | `18-buster` |

### Author
This resource is an **[official job](https://docs.r2devops.io/faq-labels/)** added in [**R2Devops repository**](https://gitlab.com/r2devops/hub) by [@GridexX](https://gitlab.com/GridexX)
 No newline at end of file
+33 −0
Original line number Diff line number Diff line
# Job from R2Devops hub --> r2devops.io

stages:
  - deploy

clever_deploy:
  image: 
    name: node:${IMAGE_TAG}
    entrypoint: [""]
  stage: deploy
  variables:
    CLEVER_BUILD_PATH: "website_build"
    CLEVER_APP: "$CI_PROJECT_PATH_SLUG"
    CLEVER_TOKEN: ""
    CLEVER_SECRET: ""
    CLEVER_PACKAGE_VERSION: "2.9.1"
    IMAGE_TAG: "18-buster"
  script:
    # Clone the remote repository with a full depth to be compatible with clever deploy 
    - git fetch --depth=2147483647
    - git remote set-branches origin '*'
    - git fetch -v

    - npm i -g clever-tools@${CLEVER_PACKAGE_VERSION}
    - clever login --token ${CLEVER_TOKEN} --secret ${CLEVER_SECRET}
    # Create the application and configure the static website with domain name and https
    - clever create --type static-apache ${CLEVER_APP}
    - clever config set force-https enabled
    - clever env set CC_WEBROOT /${CLEVER_BUILD_PATH}
    - DOMAIN=${CLEVER_APP}.cleverapps.io
    - clever domain add ${DOMAIN} || true
    - clever deploy -f
    - echo "✅ Website successfully deployed on https://${DOMAIN}"