Skip to content

Commit

Permalink
ci(deploy): add reusable deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Falinor committed May 30, 2024
1 parent 1b3576c commit c074d12
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 35 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Deploy to Clever Cloud

on:
workflow_call:
inputs:
app:
type: string
required: true
description: The app alias registered on Clever Cloud
branch:
type: string
required: true
description: The branch to deploy
secrets:
CLEVER_SECRET:
required: true
description: The Clever Cloud secret
CLEVER_TOKEN:
required: true
description: The Clever Cloud token
CLEVER_ORG:
required: true
description: The Clever Cloud organization ID

jobs:
deploy:
if: ${{ github.ref_name == inputs.branch }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install clever-tools
run: npm install -g clever-tools

- name: Deploy
env:
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
ORGA_ID: ${{ secrets.CLEVER_ORG }}
run: |
clever deploy --alias ${{ inputs.app }}
83 changes: 48 additions & 35 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,44 +67,57 @@ jobs:
- name: Test database migrations
run: yarn workspace @zerologementvacant/server run test:migrations --run-in-band

deploy-staging:
deploy-test:
uses: ./.github/workflows/deploy.yml
needs: [build]
if: github.ref_name == 'main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
app: test
branch: ci-deploy-on-clever-cloud

- name: Install clever-tools
run: npm install -g clever-tools
deploy-front-staging:
uses: ./.github/workflows/deploy.yml
needs: [build]
with:
app: front-staging
branch: main
secrets: inherit

- name: Deploy
env:
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
ORGA_ID: ${{ secrets.CLEVER_ORG }}
run: |
clever deploy --alias front-staging
clever deploy --alias api-staging
clever deploy --alias queue-staging
deploy-prod:
deploy-api-staging:
uses: ./.github/workflows/deploy.yml
needs: [build]
if: github.ref_name == 'prod'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
app: api-staging
branch: main
secrets: inherit

- name: Install clever-tools
run: npm install -g clever-tools
deploy-queue-staging:
uses: ./.github/workflows/deploy.yml
needs: [build]
with:
app: queue-staging
branch: main
secrets: inherit

- name: Deploy
env:
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
ORGA_ID: ${{ secrets.CLEVER_ORG }}
run: |
clever deploy --alias front-production
clever deploy --alias api-production
clever deploy --alias queue-production
deploy-front-production:
uses: ./.github/workflows/deploy.yml
needs: [build]
with:
app: front-production
branch: prod
secrets: inherit

deploy-api-production:
uses: ./.github/workflows/deploy.yml
needs: [build]
with:
app: api-production
branch: prod
secrets: inherit

deploy-queue-production:
uses: ./.github/workflows/deploy.yml
needs: [build]
with:
app: queue-production
branch: prod
secrets: inherit

0 comments on commit c074d12

Please sign in to comment.