fix pipeline #10
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
# 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: 02-app-service-nodejs-deploy | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
WORKING_DIRECTORY: './02-app-service-nodejs' | |
AZURE_WEBAPP_NAME: 'thaitype-azure-note-ep2' | |
AZURE_PUBLISH_PROFILE: ${{ secrets.path__02_app_service_nodejs_target__AZURE_WEBAPP_PUBLISH_PROFILE_thaitype_azure_note_ep2 }} | |
PACKAGE_NAME: 'node-app' | |
PACKAGE_PATH: 'release.zip' | |
NODE_VERSION: '20' | |
# PNPM_VERSION: '8' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# - uses: pnpm/action-setup@v3 | |
# with: | |
# version: ${{ env.PNPM_VERSION }} | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: 'npm' | |
cache-dependency-path: '${{ env.WORKING_DIRECTORY }}/package-lock.json' | |
- name: Install dependencies | |
run: npm install | |
working-directory: ${{ env.WORKING_DIRECTORY }} | |
- name: Build | |
run: npm run build | |
working-directory: ${{ env.WORKING_DIRECTORY }} | |
- name: Zip artifact for deployment | |
run: zip ${{ env.PACKAGE_PATH }} ./* -r | |
working-directory: ${{ env.WORKING_DIRECTORY }} | |
- name: Upload artifact for deployment job | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PACKAGE_NAME }} | |
path: ${{ env.WORKING_DIRECTORY }}/${{ env.PACKAGE_PATH }} | |
retention-days: 1 | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: 'production' | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
permissions: | |
id-token: write #This is required for requesting the JWT | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.PACKAGE_NAME }} | |
- name: Unzip artifact for deployment | |
run: unzip ${{ env.PACKAGE_PATH }} | |
- name: 'Deploy to Azure Web App' | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v3 | |
with: | |
app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
publish-profile: ${{ env.AZURE_PUBLISH_PROFILE }} | |
slot-name: 'production' | |
package: . | |