-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
60 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,70 @@ | ||
name: Deploy Client | ||
name: Build and deploy Node.js app to Azure Web App - devablos-client | ||
|
||
on: | ||
push: | ||
branches: | ||
- feature/deployment-setup | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-and-deploy: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js version | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
|
||
- name: Install dependencies and build client | ||
run: | | ||
cd client | ||
npm install | ||
npm run build | ||
- name: Zip artifact for deployment | ||
run: | | ||
cd client/build | ||
zip -r ../../release.zip . | ||
- 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: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd client | ||
npm install | ||
- name: Build project | ||
run: | | ||
cd client | ||
npm run build || true | ||
- name: Verify build directory | ||
run: | | ||
ls -al client/build | ||
- name: Deploy to Azure Web App | ||
uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: DevablosClientApp | ||
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_CLIENT }} | ||
package: client/build | ||
- 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.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- name: 'Deploy to Azure Web App' | ||
id: deploy-to-webapp | ||
uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: 'devablos-client' | ||
slot-name: 'production' | ||
package: . |