Build and deploy production #101
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
name: Build and deploy production | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
id-token: write | |
contents: read | |
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: Install and build | |
run: | | |
yarn | |
yarn build | |
- name: Build redirects | |
run: | | |
node ./script/redirects.js | |
- name: Copy redirects to server root | |
run: | | |
cp web.config public/ | |
- name: Upload artifact for deployment job | |
uses: actions/upload-artifact@v2 | |
with: | |
name: node-app | |
path: ./public/ | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: 'production' | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
steps: | |
- name: Az CLI login | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v2 | |
with: | |
name: node-app | |
- name: Deploy to Azure Web App service | |
uses: azure/webapps-deploy@v2 | |
id: deploy-to-webapp | |
with: | |
app-name: 'primerstyle' | |
slot-name: 'production' | |
package: . |