0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

ci: separate core and cloud deployment (#3504)

This commit is contained in:
Gao Sun 2023-03-19 15:12:54 +08:00 committed by GitHub
parent 19edaf7d17
commit d68ab0345b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,7 @@ on:
- v*.*.* - v*.*.*
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} group: ${{ github.workflow }}-${{ github.ref }}
jobs: jobs:
dockerize-core: dockerize-core:
@ -135,9 +135,9 @@ jobs:
build-args: | build-args: |
admin_endpoint=https://auth.logto.${{ inputs.target == 'prod' && 'io' || 'dev' }}/ admin_endpoint=https://auth.logto.${{ inputs.target == 'prod' && 'io' || 'dev' }}/
deploy: deploy-core:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [dockerize-core, dockerize-cloud] needs: dockerize-core
environment: ${{ inputs.target || 'dev' }} environment: ${{ inputs.target || 'dev' }}
if: ${{ !startsWith(github.ref, 'refs/tags/') }} if: ${{ !startsWith(github.ref, 'refs/tags/') }}
@ -160,13 +160,6 @@ jobs:
env: env:
DB_URL: ${{ secrets.DB_URL }} DB_URL: ${{ secrets.DB_URL }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: silverhand-bot
password: ${{ secrets.BOT_PAT }}
- name: Login via Azure CLI - name: Login via Azure CLI
uses: azure/login@v1 uses: azure/login@v1
with: with:
@ -179,6 +172,35 @@ jobs:
slot-name: staging slot-name: staging
images: ghcr.io/logto-io/logto:sha-${{ steps.sha.outputs.short }} images: ghcr.io/logto-io/logto:sha-${{ steps.sha.outputs.short }}
- name: Swap core to production
# See https://learn.microsoft.com/en-us/cli/azure/webapp/deployment/slot?view=azure-cli-latest#az-webapp-deployment-slot-swap
run: az webapp deployment slot swap -g ${{ vars.RESOURCE_GROUP }} -n ${{ vars.APP_NAME_CORE }} --slot staging
deploy-cloud:
runs-on: ubuntu-latest
needs: dockerize-cloud
environment: ${{ inputs.target || 'dev' }}
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/checkout@v3
- name: Set short sha
id: sha
run: echo "short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: silverhand-bot
password: ${{ secrets.BOT_PAT }}
- name: Login via Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy cloud to containerapp - name: Deploy cloud to containerapp
uses: azure/webapps-deploy@v2 uses: azure/webapps-deploy@v2
with: with:
@ -186,10 +208,6 @@ jobs:
slot-name: staging slot-name: staging
images: ghcr.io/logto-io/cloud:sha-${{ steps.sha.outputs.short }} images: ghcr.io/logto-io/cloud:sha-${{ steps.sha.outputs.short }}
- name: Swap core to production
# See https://learn.microsoft.com/en-us/cli/azure/webapp/deployment/slot?view=azure-cli-latest#az-webapp-deployment-slot-swap
run: az webapp deployment slot swap -g ${{ vars.RESOURCE_GROUP }} -n ${{ vars.APP_NAME_CORE }} --slot staging
- name: Swap cloud to production - name: Swap cloud to production
# See https://learn.microsoft.com/en-us/cli/azure/webapp/deployment/slot?view=azure-cli-latest#az-webapp-deployment-slot-swap # See https://learn.microsoft.com/en-us/cli/azure/webapp/deployment/slot?view=azure-cli-latest#az-webapp-deployment-slot-swap
run: az webapp deployment slot swap -g ${{ vars.RESOURCE_GROUP }} -n ${{ vars.APP_NAME_CLOUD }} --slot staging run: az webapp deployment slot swap -g ${{ vars.RESOURCE_GROUP }} -n ${{ vars.APP_NAME_CLOUD }} --slot staging