Skip to content

Instantly share code, notes, and snippets.

@DanRibbens
Created February 1, 2022 17:54
Show Gist options
  • Save DanRibbens/cc94d9d76e76242dd6122b2f9f1fef17 to your computer and use it in GitHub Desktop.
Save DanRibbens/cc94d9d76e76242dd6122b2f9f1fef17 to your computer and use it in GitHub Desktop.
Build and deploy github action Payload + Next.js to Azure Web App
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Payload + Next app to Azure Web App
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: yarn install, build, and test
env:
PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET }}
MONGO_URL: ${{ secrets.MONGO_URL }}
NEXT_PUBLIC_SERVER_URL: ${{ secrets.NEXT_PUBLIC_SERVER_URL }}
PAYLOAD_PUBLIC_SERVER_URL: ${{ secrets.PAYLOAD_PUBLIC_SERVER_URL }}
PAYLOAD_LICENSE: ${{ secrets.PAYLOAD_LICENSE }}
run: |
yarn
yarn build
# yarn test # enable if you have tests to verify before deployment
working-directory: .
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: node-app
path: |
package.json
./dist
./build
./.next
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: node-app
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'preneed'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_0123456789_YOUR_ID }}
package: .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment