Skip to content
on:
push:
branches:
- feature
pull_request:
branches:
- main
- develop
env:
AZURE_WEBAPP_NAME: L5-M3-Test
AZURE_WEBAPP_NAME2: L5-M3-2
AZURE_WEBAPP_PACKAGE_PATH: '.'
NODE_VERSION: '16.x'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: npm install, build and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: Upload artifact for deployment
uses: actions/upload-artifact@v3
with:
name: node-app
path: .
deploy-to-test:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'pull_request' && github.base_ref == 'refs/heads/develop'
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: node-app
- name: 'Deploy to Azure Webapp Test (L5-M3-Test)'
id: deploy-to-webapp
uses: azure/webapps-deploy@85270a1854658d167ab239bce43949edb336fa7c
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
deploy-to-production:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'pull_request' && github.base_ref == 'refs/heads/main'
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: node-app
- name: 'Deploy to Azure Webapp Production (L5-M3-2)'
id: deploy-to-webapp
uses: azure/webapps-deploy@85270a1854658d167ab239bce43949edb336fa7c
with:
app-name: ${{ env.AZURE_WEBAPP_NAME2 }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}