Skip to content

Merge pull request #67 from mikeller/dependabot/npm_and_yarn/service/… #26

Merge pull request #67 from mikeller/dependabot/npm_and_yarn/service/…

Merge pull request #67 from mikeller/dependabot/npm_and_yarn/service/… #26

name: Build and deploy Node.js app to Azure Web App - garmin-divesite-weather-widget-service
on:
push:
branches:
- master
paths:
- 'service/**'
- .github/workflows/master_garmin-divesite-weather-widget-service.yml
pull_request:
branches:
- master
paths:
- 'service/**'
- .github/workflows/master_garmin-divesite-weather-widget-service.yml
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: |
cd service
npm install
npm run build --if-present
npm run test --if-present
- name: Zip artifact for deployment
run: |
cd service
zip ../release.zip ./* -r
- name: Upload artifact for deployment job
if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: node-app
path: release.zip
deploy:
runs-on: ubuntu-latest
if: github.event_name == 'push'
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: node-app
- name: Unzip artifact for deployment
run: unzip release.zip
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_56115497CDBA4D51B2FFC4D09078FE2E }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_CA4D87AA4CBA44BC8C77395DA5EBFD0D }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_2538986614A046478CC35335D00F20B8 }}
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'garmin-divesite-weather-widget-service'
slot-name: 'Production'
package: .
smoke-test:
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: deploy
steps:
- name: check uptime
run: |
sleep 180
UPTIME=$(curl https://garmin-divesite-weather-widget-service.azurewebsites.net/status | jq -r ".uptime" | awk '{print int($1)}')
if [[ "${UPTIME}" -gt 360 ]]; then
echo "Service has not been restarted recently"
exit 1
else
echo "Service uptime is ${UPTIME}."
fi
- name: check response
run: |
curl https://garmin-divesite-weather-widget-service.azurewebsites.net/data\?lat=-43\&lon=171 | jq -e ".properties.timeseries"
if [[ $? -ne 0 ]]; then
echo "Service did not return a timeseries"
exit 1
fi