From b6faeea96a95acd55dfe9a21358182e58885d3b4 Mon Sep 17 00:00:00 2001 From: inimaz <93inigo93@gmail.com> Date: Fri, 24 Jan 2025 19:21:41 +0100 Subject: [PATCH 1/7] ci: deploy app from ci --- .github/workflows/deploy.yml | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..0607e7eef --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,41 @@ +name: Deploy to Clever Cloud + +on: + pull_request_target: + types: [opened, synchronize, reopened] + branches: [ main ] + workflow_dispatch: # Allow manual triggering for either environment + +jobs: + staging: + if: github.event_name == 'pull_request' || github.event.action == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - 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 login --token ${{ secrets.CLEVER_TOKEN }} --secret ${{ secrets.CLEVER_SECRET }} + + - name: Deploy backend to Clever Cloud (Staging) + env: + CLEVER_APP_ID: ${{ secrets.BE_CLEVER_APP_ID_STAGING }} + run: | + clever link $CLEVER_APP_ID + clever deploy + + - name: Deploy frontend to Clever Cloud (Staging) + env: + CLEVER_APP_ID: ${{ secrets.FE_CLEVER_APP_ID_STAGING }} + run: | + clever link $CLEVER_APP_ID + clever deploy \ No newline at end of file From 673318d1d9ea1594661a22baa359e61d54dcf5d0 Mon Sep 17 00:00:00 2001 From: inimaz <93inigo93@gmail.com> Date: Sun, 26 Jan 2025 12:31:40 +0100 Subject: [PATCH 2/7] test triggering the deploy Signed-off-by: inimaz <93inigo93@gmail.com> --- .github/workflows/deploy.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0607e7eef..61dbc4231 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,14 +1,15 @@ name: Deploy to Clever Cloud on: - pull_request_target: - types: [opened, synchronize, reopened] - branches: [ main ] - workflow_dispatch: # Allow manual triggering for either environment + pull_request: + # pull_request_target: + # types: [opened, synchronize, reopened] + # branches: [ main ] + # workflow_dispatch: # Allow manual triggering for either environment jobs: staging: - if: github.event_name == 'pull_request' || github.event.action == 'workflow_dispatch' + # if: github.event_name == 'pull_request' || github.event.action == 'workflow_dispatch' runs-on: ubuntu-latest steps: - name: Checkout code From 74e05dd677201574d6210cf3ce3612356382adf4 Mon Sep 17 00:00:00 2001 From: inimaz <93inigo93@gmail.com> Date: Sun, 26 Jan 2025 12:34:04 +0100 Subject: [PATCH 3/7] fix: add reference to local clever cli --- .github/workflows/deploy.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 61dbc4231..b9c4de12c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,18 +25,18 @@ jobs: - name: Login to Clever Cloud env: CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }} - run: clever login --token ${{ secrets.CLEVER_TOKEN }} --secret ${{ secrets.CLEVER_SECRET }} + run: ./clever-tools-latest_linux/clever login --token ${{ secrets.CLEVER_TOKEN }} --secret ${{ secrets.CLEVER_SECRET }} - name: Deploy backend to Clever Cloud (Staging) env: CLEVER_APP_ID: ${{ secrets.BE_CLEVER_APP_ID_STAGING }} run: | - clever link $CLEVER_APP_ID - clever deploy + ./clever-tools-latest_linux/clever link $CLEVER_APP_ID + ./clever-tools-latest_linux/clever deploy - name: Deploy frontend to Clever Cloud (Staging) env: CLEVER_APP_ID: ${{ secrets.FE_CLEVER_APP_ID_STAGING }} run: | - clever link $CLEVER_APP_ID - clever deploy \ No newline at end of file + ./clever-tools-latest_linux/clever link $CLEVER_APP_ID + ./clever-tools-latest_linux/clever deploy \ No newline at end of file From 6531b17fc1ae10776282626dda960965e677a43e Mon Sep 17 00:00:00 2001 From: inimaz <93inigo93@gmail.com> Date: Sun, 26 Jan 2025 12:41:49 +0100 Subject: [PATCH 4/7] unshallow the fetch Signed-off-by: inimaz <93inigo93@gmail.com> --- .github/workflows/deploy.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b9c4de12c..867ee0245 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,6 +14,9 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 # Same as git fetch --unshallow + clean: true # Remove any untracked files or modifications - name: Install Clever Tools CLI run: | @@ -32,11 +35,11 @@ jobs: CLEVER_APP_ID: ${{ secrets.BE_CLEVER_APP_ID_STAGING }} run: | ./clever-tools-latest_linux/clever link $CLEVER_APP_ID - ./clever-tools-latest_linux/clever deploy + ./clever-tools-latest_linux/clever deploy -f - name: Deploy frontend to Clever Cloud (Staging) env: CLEVER_APP_ID: ${{ secrets.FE_CLEVER_APP_ID_STAGING }} run: | ./clever-tools-latest_linux/clever link $CLEVER_APP_ID - ./clever-tools-latest_linux/clever deploy \ No newline at end of file + ./clever-tools-latest_linux/clever deploy -f \ No newline at end of file From d414adccc5cc6f356b0c82e20db596def1b1d001 Mon Sep 17 00:00:00 2001 From: inimaz <93inigo93@gmail.com> Date: Sun, 26 Jan 2025 13:22:21 +0100 Subject: [PATCH 5/7] fix: deploy to multiple applications using --alias APP_NAME Signed-off-by: inimaz <93inigo93@gmail.com> --- .github/workflows/deploy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 867ee0245..c70e3cb02 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,13 +33,15 @@ jobs: - name: Deploy backend to Clever Cloud (Staging) env: CLEVER_APP_ID: ${{ secrets.BE_CLEVER_APP_ID_STAGING }} + APP_NAME: cc_api_test run: | ./clever-tools-latest_linux/clever link $CLEVER_APP_ID - ./clever-tools-latest_linux/clever deploy -f + ./clever-tools-latest_linux/clever deploy -f -a $APP_NAME - name: Deploy frontend to Clever Cloud (Staging) env: CLEVER_APP_ID: ${{ secrets.FE_CLEVER_APP_ID_STAGING }} + APP_NAME: cc_dashboard_dev run: | ./clever-tools-latest_linux/clever link $CLEVER_APP_ID - ./clever-tools-latest_linux/clever deploy -f \ No newline at end of file + ./clever-tools-latest_linux/clever deploy -f -a $APP_NAME \ No newline at end of file From d93ba1c09591bf87be19ddd48fa6b041b3548cdb Mon Sep 17 00:00:00 2001 From: inimaz <93inigo93@gmail.com> Date: Sun, 26 Jan 2025 13:32:43 +0100 Subject: [PATCH 6/7] reduce verbosity of deploy logs (no need for app logs) Signed-off-by: inimaz <93inigo93@gmail.com> --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c70e3cb02..885fc704d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -36,7 +36,7 @@ jobs: APP_NAME: cc_api_test run: | ./clever-tools-latest_linux/clever link $CLEVER_APP_ID - ./clever-tools-latest_linux/clever deploy -f -a $APP_NAME + ./clever-tools-latest_linux/clever deploy -f -a $APP_NAME --quiet - name: Deploy frontend to Clever Cloud (Staging) env: @@ -44,4 +44,4 @@ jobs: APP_NAME: cc_dashboard_dev run: | ./clever-tools-latest_linux/clever link $CLEVER_APP_ID - ./clever-tools-latest_linux/clever deploy -f -a $APP_NAME \ No newline at end of file + ./clever-tools-latest_linux/clever deploy -f -a $APP_NAME --quiet \ No newline at end of file From ac5aeb465db9e01b35ebb1200ecd00e17d924291 Mon Sep 17 00:00:00 2001 From: inimaz <93inigo93@gmail.com> Date: Sun, 26 Jan 2025 16:47:49 +0100 Subject: [PATCH 7/7] . --- .github/workflows/deploy.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 885fc704d..5836f22da 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,15 +1,11 @@ name: Deploy to Clever Cloud on: - pull_request: - # pull_request_target: - # types: [opened, synchronize, reopened] - # branches: [ main ] - # workflow_dispatch: # Allow manual triggering for either environment + push: + branches: [master] jobs: - staging: - # if: github.event_name == 'pull_request' || github.event.action == 'workflow_dispatch' + production: runs-on: ubuntu-latest steps: - name: Checkout code @@ -30,18 +26,18 @@ jobs: 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) + - name: Deploy backend to Clever Cloud (PROD) env: - CLEVER_APP_ID: ${{ secrets.BE_CLEVER_APP_ID_STAGING }} - APP_NAME: cc_api_test + 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 -a $APP_NAME --quiet - - name: Deploy frontend to Clever Cloud (Staging) + - name: Deploy frontend to Clever Cloud (PROD) env: - CLEVER_APP_ID: ${{ secrets.FE_CLEVER_APP_ID_STAGING }} - APP_NAME: cc_dashboard_dev + CLEVER_APP_ID: ${{ secrets.FE_CLEVER_APP_ID_PROD }} + APP_NAME: cc_dashboard_prod run: | ./clever-tools-latest_linux/clever link $CLEVER_APP_ID ./clever-tools-latest_linux/clever deploy -f -a $APP_NAME --quiet \ No newline at end of file