Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/actions/deploy-clever-cloud/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Deploy the checked-out repository (API and/or static UI) to Clever Cloud.
# The caller must check out the code to deploy (with fetch-depth: 0) in the workspace root;
# the action itself can be referenced with `uses: $/.github/actions/deploy-clever-cloud`.
name: Deploy to Clever Cloud
description: Install Clever Tools, log in, and deploy the API and/or UI apps

inputs:
target:
description: "What to deploy: both, api or ui"
required: false
default: both
clever-token:
description: Clever Cloud token
required: true
clever-secret:
description: Clever Cloud secret
required: true
backend-app-id:
description: Clever Cloud app ID of the API (required unless target is ui)
required: false
frontend-app-id:
description: Clever Cloud app ID of the static SPA (required unless target is api)
required: false
frontend-app-alias:
description: Clever Cloud alias of the static SPA (required unless target is api)
required: false

runs:
using: composite
steps:
- name: Check inputs
shell: bash
env:
TARGET: ${{ inputs.target }}
BE_APP_ID: ${{ inputs.backend-app-id }}
FE_APP_ID: ${{ inputs.frontend-app-id }}
FE_APP_ALIAS: ${{ inputs.frontend-app-alias }}
run: |
case "$TARGET" in
both|api|ui) ;;
*) echo "::error::Invalid target '$TARGET', expected both, api or ui"; exit 1 ;;
esac
if [ "$TARGET" != ui ] && [ -z "$BE_APP_ID" ]; then
echo "::error::backend-app-id is required to deploy the API"; exit 1
fi
if [ "$TARGET" != api ] && { [ -z "$FE_APP_ID" ] || [ -z "$FE_APP_ALIAS" ]; }; then
echo "::error::frontend-app-id and frontend-app-alias are required to deploy the UI"; exit 1
fi

- name: Install Clever Tools CLI
shell: bash
run: |
CC_VERSION=latest
curl -s -O https://clever-tools.clever-cloud.com/releases/${CC_VERSION}/clever-tools-${CC_VERSION}_linux.tar.gz
tar -xf clever-tools-${CC_VERSION}_linux.tar.gz -C "$RUNNER_TEMP"
rm clever-tools-${CC_VERSION}_linux.tar.gz
echo "$RUNNER_TEMP/clever-tools-${CC_VERSION}_linux" >> "$GITHUB_PATH"

- name: Login to Clever Cloud
shell: bash
env:
CLEVER_TOKEN: ${{ inputs.clever-token }}
CLEVER_SECRET: ${{ inputs.clever-secret }}
run: clever login --token "$CLEVER_TOKEN" --secret "$CLEVER_SECRET"

- name: Deploy backend to Clever Cloud
if: inputs.target != 'ui'
shell: bash
env:
CLEVER_APP_ID: ${{ inputs.backend-app-id }}
run: |
clever link "$CLEVER_APP_ID"
clever deploy -f

- name: Deploy frontend (static SPA) to Clever Cloud
if: inputs.target != 'api'
shell: bash
env:
CLEVER_APP_ID: ${{ inputs.frontend-app-id }}
CLEVER_APP_ALIAS: ${{ inputs.frontend-app-alias }}
run: |
clever link "$CLEVER_APP_ID"
clever deploy -a "$CLEVER_APP_ALIAS" -f
40 changes: 11 additions & 29 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,14 @@ jobs:
fetch-depth: 0 # Same as git fetch --unshallow
clean: true # Remove any untracked files or modifications

- name: Install Clever Tools CLI
run: |
CC_VERSION=latest
curl -s -O https://clever-tools.clever-cloud.com/releases/${CC_VERSION}/clever-tools-${CC_VERSION}_linux.tar.gz
tar -xvf clever-tools-${CC_VERSION}_linux.tar.gz
PATH=${PATH}:$(pwd)/clever-tools-${CC_VERSION}_linux

- name: Login to Clever Cloud
env:
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
run: ./clever-tools-latest_linux/clever login --token ${{ secrets.CLEVER_TOKEN }} --secret ${{ secrets.CLEVER_SECRET }}

- name: Deploy backend to Clever Cloud (STAGING)
if: inputs.target != 'ui'
env:
CLEVER_APP_ID: ${{ secrets.BE_CLEVER_APP_ID_STAGING }}
APP_NAME: cc_api_staging
run: |
./clever-tools-latest_linux/clever link $CLEVER_APP_ID
./clever-tools-latest_linux/clever deploy -f

- name: Deploy frontend (static SPA) to Clever Cloud (STAGING)
if: inputs.target != 'api'
env:
CLEVER_APP_ID: ${{ secrets.FE_CLEVER_APP_ID_STAGING }}
CLEVER_APP_ALIAS: ${{ secrets.FE_CLEVER_APP_ALIAS_STAGING }}
run: |
./clever-tools-latest_linux/clever link $CLEVER_APP_ID
./clever-tools-latest_linux/clever deploy -a $CLEVER_APP_ALIAS -f
# $/ loads the action from the dispatched branch, not from the checked-out PR,
# so a fork can't change the steps that run with the Clever Cloud secrets.
- name: Deploy to Clever Cloud (STAGING)
uses: $/.github/actions/deploy-clever-cloud
with:
target: ${{ inputs.target }}
clever-token: ${{ secrets.CLEVER_TOKEN }}
clever-secret: ${{ secrets.CLEVER_SECRET }}
backend-app-id: ${{ secrets.BE_CLEVER_APP_ID_STAGING }}
frontend-app-id: ${{ secrets.FE_CLEVER_APP_ID_STAGING }}
frontend-app-alias: ${{ secrets.FE_CLEVER_APP_ALIAS_STAGING }}
35 changes: 8 additions & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,11 @@ jobs:
fetch-depth: 0 # Same as git fetch --unshallow
clean: true # Remove any untracked files or modifications

- name: Install Clever Tools CLI
run: |
CC_VERSION=latest
curl -s -O https://clever-tools.clever-cloud.com/releases/${CC_VERSION}/clever-tools-${CC_VERSION}_linux.tar.gz
tar -xvf clever-tools-${CC_VERSION}_linux.tar.gz
PATH=${PATH}:$(pwd)/clever-tools-${CC_VERSION}_linux

- name: Login to Clever Cloud
env:
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
run: ./clever-tools-latest_linux/clever login --token ${{ secrets.CLEVER_TOKEN }} --secret ${{ secrets.CLEVER_SECRET }}

- name: Deploy backend to Clever Cloud (PROD)
env:
CLEVER_APP_ID: ${{ secrets.BE_CLEVER_APP_ID_PROD }}
APP_NAME: cc_api_prod
run: |
./clever-tools-latest_linux/clever link $CLEVER_APP_ID
./clever-tools-latest_linux/clever deploy -f

- name: Deploy frontend (static SPA) to Clever Cloud (PROD)
env:
CLEVER_APP_ID: ${{ secrets.FE_CLEVER_APP_ID_PROD }}
CLEVER_APP_ALIAS: ${{ secrets.FE_CLEVER_APP_ALIAS_PROD }}
run: |
./clever-tools-latest_linux/clever link $CLEVER_APP_ID
./clever-tools-latest_linux/clever deploy -a $CLEVER_APP_ALIAS -f
- name: Deploy to Clever Cloud (PROD)
uses: $/.github/actions/deploy-clever-cloud
with:
clever-token: ${{ secrets.CLEVER_TOKEN }}
clever-secret: ${{ secrets.CLEVER_SECRET }}
backend-app-id: ${{ secrets.BE_CLEVER_APP_ID_PROD }}
frontend-app-id: ${{ secrets.FE_CLEVER_APP_ID_PROD }}
frontend-app-alias: ${{ secrets.FE_CLEVER_APP_ALIAS_PROD }}
Loading