Merge branch 'pr-90' into development #54
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: UI - DEV - CI/CD | |
on: | |
push: | |
branches: | |
- development | |
paths: | |
- 'ui/**' | |
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 | |
working-directory: ./ui | |
run: | | |
npm install | |
npm run build --if-present | |
npm run test --if-present | |
- name: Zip artifact for deployment | |
working-directory: ./ui | |
run: | | |
cd build | |
zip -r ../release.zip ./* | |
- name: Upload artifact for deployment job | |
uses: actions/upload-artifact@v4 | |
with: | |
name: node-app | |
path: ./ui/release.zip | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: 'dev' | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: node-app | |
path: . | |
- name: List contents of the downloaded artifact directory | |
run: ls -R . | |
- name: Unzip artifact into wwwroot | |
run: unzip ./release.zip -d wwwroot | |
- name: List contents of wwwroot directory | |
run: ls -R wwwroot | |
- name: 'Login to Azure' | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_SERVICE_PRINCIPAL }} | |
- name: 'Deploy to Azure Web App' | |
uses: azure/webapps-deploy@v3 | |
with: | |
app-name: 'devcamper-webapp' # Replace with your Azure App Service name | |
slot-name: 'dev' # Specify the slot name (e.g., 'dev' for development slot) | |
package: wwwroot | |
- name: 'Validate Deployment' | |
run: | | |
response=$(curl --write-out '%{http_code}' --silent --output /dev/null https://devcamper-webapp-dev.azurewebsites.net) | |
if [ "$response" -ne 200 ]; then | |
echo "Deployment validation failed with status code $response" | |
exit 1 | |
else | |
echo "Deployment validation succeeded with status code $response" | |
fi |