updating the pipeline

This commit is contained in:
Ammar Qaffaf
2024-02-22 02:04:06 +03:00
parent 03c2dbf1d3
commit 2f4364abb3
3 changed files with 21 additions and 151 deletions

View File

@ -1,59 +0,0 @@
on:
push:
branches: [ "dev" ]
workflow_dispatch:
env:
AZURE_WEBAPP_NAME: backend-dev # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '20.x' # set this to the node version to use
permissions:
contents: read
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 job
uses: actions/upload-artifact@v3
with:
name: node-app
path: .
deploy:
permissions:
contents: none
runs-on: ubuntu-latest
needs: build
environment:
name: 'Development'
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'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

View File

@ -1,6 +1,3 @@
# 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 Node.js app to Azure Web App - syncrow name: Build and deploy Node.js app to Azure Web App - syncrow
on: on:
@ -9,6 +6,11 @@ on:
- dev - dev
workflow_dispatch: workflow_dispatch:
env:
NODE_VERSION: '20.x'
AZURE_WEB_APP_NAME: 'syncrow'
AZURE_SLOT_NAME: 'dev'
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -16,10 +18,11 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Node.js version - name: Set up Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: '20.x' node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: npm install, build, and test - name: npm install, build, and test
run: | run: |
@ -28,7 +31,7 @@ jobs:
npm run test --if-present npm run test --if-present
- name: Zip artifact for deployment - name: Zip artifact for deployment
run: zip release.zip ./* -r run: zip -r release.zip . -x node_modules\* \*.git\* \*.github\* \*tests\*
- name: Upload artifact for deployment job - name: Upload artifact for deployment job
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
@ -41,9 +44,10 @@ jobs:
needs: build needs: build
environment: environment:
name: 'dev' name: 'dev'
# Dynamically set or adjust as needed
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions: permissions:
id-token: write #This is required for requesting the JWT id-token: write # For federated credentials, if applicable
steps: steps:
- name: Download artifact from build job - name: Download artifact from build job
@ -53,19 +57,15 @@ jobs:
- name: Unzip artifact for deployment - name: Unzip artifact for deployment
run: unzip release.zip run: unzip release.zip
- name: Login to Azure - name: Login to Azure
uses: azure/login@v1 uses: azure/login@v2
with: with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_B0E5D07AA5C94CCABC05A696CFDFA185 }} creds: ${{ secrets.AZURE_CREDENTIALS }} # JSON Service Principal credentials for Azure in a secret
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_D2A87194F5BF4F2CA24CE8C4D3EDDF24 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_4E6606241F0B4089BAFF050BC609DDE0 }}
- name: 'Deploy to Azure Web App' - name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2 uses: azure/webapps-deploy@v2
with: with:
app-name: 'syncrow' app-name: ${{ env.AZURE_WEB_APP_NAME }}
slot-name: 'dev' slot-name: ${{ env.AZURE_SLOT_NAME }}
package: . package: release.zip

View File

@ -1,71 +0,0 @@
# 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 Node.js app to Azure Web App - syncrow-dev
on:
push:
branches:
- dev
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: Zip artifact for deployment
run: zip release.zip ./* -r
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: node-app
path: release.zip
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@v3
with:
name: node-app
- name: Unzip artifact for deployment
run: unzip release.zip
- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F5089EEA95DF450E90E990B230B63FEA }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_6A9379B9B88748918EE02EE725C051AD }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_8041F0A416EB4B24ADE667B446A2BD0D }}
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'syncrow-dev'
slot-name: 'Production'
package: .