-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and improve deployment workflow using environments (#773)
* Fix and improve deployment workflow using environments * Fix workflow * Try to fix path to deployment * Fix database reset * Fix slot name * Remove debugging output from workflow * Fix apollo link * Fix apollo link * Only import redis-mock for local dev * Fix import * Also make env availabe in client runtime config
- Loading branch information
1 parent
d505726
commit f328638
Showing
7 changed files
with
102 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ on: | |
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
build: | ||
name: Build | ||
|
||
runs-on: ubuntu-latest | ||
|
||
|
@@ -36,6 +36,7 @@ jobs: | |
- name: Setup Node.js | ||
uses: actions/[email protected] | ||
with: | ||
# Should be kept in sync with version configured in Azure | ||
node-version: 14.x | ||
cache: 'yarn' | ||
|
||
|
@@ -48,70 +49,91 @@ jobs: | |
- name: Prepare artifact | ||
run: | | ||
mkdir artifact | ||
cp -r .nuxt nuxt.config.ts package.json config.ts ./api ./static ./node_modules artifact | ||
cp -r .output ecosystem.config.js artifact | ||
- name: Upload build artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: server-build | ||
path: artifact | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
needs: build | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- environment: Test | ||
url: https://jabref-dev.azurewebsites.net/ | ||
- environment: Staging | ||
url: https://jabref-staging.azurewebsites.net/ | ||
|
||
name: Deploy to ${{ matrix.environment }} | ||
|
||
environment: | ||
name: ${{ matrix.environment }} | ||
url: ${{ matrix.url }} | ||
|
||
steps: | ||
- name: Download build artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: server-build | ||
|
||
- name: Login to Azure | ||
uses: Azure/login@v1 | ||
with: | ||
creds: ${{secrets.AZURE_CREDENTIALS}} | ||
|
||
- name: Start deployment (Test server) | ||
uses: bobheadxi/[email protected] | ||
id: deployment-test | ||
with: | ||
step: start | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
env: Test | ||
|
||
- name: Deploy to Azure WebApp (Test server) | ||
- name: Deploy to Azure WebApp | ||
uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: JabRef | ||
publish-profile: ${{ secrets.AZURE_TEST_PUBLISH_PROFILE }} | ||
package: ./artifact | ||
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/[email protected] | ||
with: | ||
node-version: 14.x | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Reset database on Azure (Test database) | ||
if: matrix.environment == 'Test' | ||
run: yarn prisma:migrate:reset --force | ||
env: | ||
DATABASE_URL: ${{ secrets.AZURE_TEST_DATABASE_URL }} | ||
|
||
- name: Update deployment status (Test server) | ||
uses: bobheadxi/[email protected] | ||
if: always() | ||
with: | ||
step: finish | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
status: ${{ job.status }} | ||
deployment_id: ${{ steps.deployment-test.outputs.deployment_id }} | ||
env_url: https://jabref-dev.azurewebsites.net/ | ||
|
||
- name: Start deployment (Staging server) | ||
uses: bobheadxi/[email protected] | ||
id: deployment-staging | ||
with: | ||
step: start | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
env: Staging | ||
|
||
- name: Deploy to Azure WebApp (Staging server) | ||
uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: JabRef | ||
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }} | ||
package: ./artifact | ||
|
||
- name: Update database on Azure (Production database) | ||
if: matrix.environment == 'Staging' | ||
run: yarn prisma:migrate:deploy | ||
env: | ||
DATABASE_URL: ${{ secrets.AZURE_DATABASE_URL }} | ||
|
||
- name: Update deployment status (Staging server) | ||
uses: bobheadxi/[email protected] | ||
if: always() | ||
deploy-prod: | ||
name: Deploy to Production | ||
|
||
runs-on: ubuntu-latest | ||
|
||
needs: deploy | ||
|
||
environment: | ||
name: Production | ||
url: https://jabref.azurewebsites.net/ | ||
|
||
steps: | ||
- name: Login to Azure | ||
uses: Azure/login@v1 | ||
with: | ||
step: finish | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
status: ${{ job.status }} | ||
deployment_id: ${{ steps.deployment-staging.outputs.deployment_id }} | ||
env_url: https://jabref-staging.azurewebsites.net/ | ||
creds: ${{secrets.AZURE_CREDENTIALS}} | ||
|
||
- name: Swap staging and production deployment slots | ||
run: az webapp deployment slot swap -g JabRefOnline -n JabRef --slot staging --target-slot production | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
apps: [ | ||
{ | ||
name: 'JabRefOnline', | ||
// https://pm2.keymetrics.io/docs/usage/cluster-mode/ | ||
exec_mode: 'cluster', | ||
instances: 'max', | ||
script: './.output/server/index.mjs', | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters