Skip to content

Commit

Permalink
Merge pull request #19 from varianter/chore/gh/prod-actions
Browse files Browse the repository at this point in the history
add config to gh action
  • Loading branch information
jonasbjoralt authored Sep 12, 2023
2 parents b0e9d4f + 1826656 commit 52577a4
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 115 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-backend-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
jobs:
build-backend-and-deploy:
runs-on: ubuntu-latest
environment: Development

steps:
# Checkout the repo
Expand All @@ -41,5 +42,5 @@ jobs:
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_BACKEND }} # Define secret variable in repository settings as per action documentation
package: 'backend/${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/build'
40 changes: 40 additions & 0 deletions .github/workflows/deploy-backend-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: .NET Core CI

on:
workflow_dispatch:

env:
AZURE_WEBAPP_NAME: vibes-backend-prod # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: './backend' # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: '7.x.x' # set this to the dot net version to use

jobs:
build-backend-and-deploy:
runs-on: ubuntu-latest
environment: Production

steps:
# Checkout the repo
- uses: actions/checkout@main

# Setup .NET Core SDK
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

# Run dotnet build and publish
- name: dotnet build and publish
working-directory: backend/
run: |
dotnet restore
dotnet build --configuration Release
dotnet publish -c Release --property:PublishDir='${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/build'
# Deploy to Azure Web apps
- name: 'Run Azure webapp deploy action using publish profile credentials'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_BACKEND }} # Define secret variable in repository settings as per action documentation
package: 'backend/${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/build'
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: Development

defaults:
run:
Expand Down Expand Up @@ -62,5 +63,5 @@ jobs:
with:
app-name: 'vibes-frontend-dev'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_0C39565DAE914E5895018725FE15B142 }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_FRONTEND }}
package: ./frontend/build/standalone
62 changes: 62 additions & 0 deletions .github/workflows/deploy-frontend-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

# Primary ref: https://dev.to/ckgrafico/deploying-nextjs-to-azure-web-app-with-github-actions-1o9c

name: Next.js deploy

on:
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: Production

defaults:
run:
working-directory: frontend

steps:
- name: 'Checkout'
uses: actions/checkout@v3

- name: 'Setup Node.js version'
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: 'Restore cache'
uses: actions/cache@v3
with:
path: |
frontend/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
- name: 'Install ci dependencies'
run: yarn --frozen-lockfile --ignore-scripts

- name: 'Build with Next.js'
run: |
yarn build
mv ./build/static ./build/standalone/build
mv ./public ./build/standalone
env:
NEXT_PUBLIC_VIBES_BACKEND_URL: ${{ vars.NEXT_PUBLIC_VIBES_BACKEND_URL }}
NEXT_PUBLIC_CLIENT_ID: ${{ vars.NEXT_PUBLIC_CLIENT_ID }}
NEXT_PUBLIC_TENANT_ID: ${{ vars.NEXT_PUBLIC_TENANT_ID }}
NEXT_PUBLIC_APP_SCOPE: ${{ vars.NEXT_PUBLIC_APP_SCOPE }}


- name: 'Deploy to Azure Web App (standalone)'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'vibes-frontend-prod'
slot-name: 'Production'
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_FRONTEND }}
package: ./frontend/build/standalone
57 changes: 0 additions & 57 deletions .github/workflows/main_vibes-backend-prod.yml

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/main_vibes-frontend-prod.yml

This file was deleted.

0 comments on commit 52577a4

Please sign in to comment.