From 5e8fd4492982a285f777c5c21c45eb5f86b59c82 Mon Sep 17 00:00:00 2001 From: Andrei Date: Fri, 5 Apr 2024 22:32:34 +1000 Subject: [PATCH] on build not deploy git actions --- .github/workflows/main_slipspace.yml | 45 +++++++++++++--------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/.github/workflows/main_slipspace.yml b/.github/workflows/main_slipspace.yml index 761e795..2926a16 100644 --- a/.github/workflows/main_slipspace.yml +++ b/.github/workflows/main_slipspace.yml @@ -1,3 +1,6 @@ +# 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 - slipspace on: @@ -16,19 +19,27 @@ jobs: - name: Set up Node.js version uses: actions/setup-node@v3 with: - node-version: '20.x' + node-version: '14.x' + + - name: Install dependencies + run: npm install - - name: npm install, build, and test + - name: Build React app + run: npm run build + + - name: Set environment variables run: | - npm install - npm run build --if-present - npm run test --if-present + echo "REACT_APP_GOOGLE_MAPS_API_KEY=${{ secrets.REACT_APP_GOOGLE_MAPS_API_KEY }}" >> .env.production + echo "TRIPADVISOR_API_KEY_ENV=${{ secrets.TRIPADVISOR_API_KEY_ENV }}" >> .env.production + echo "DUFFEL_API_KEY_ENV=${{ secrets.DUFFEL_API_KEY_ENV }}" >> .env.production + echo "OAG_API_KEY_ENV=${{ secrets.OAG_API_KEY_ENV }}" >> .env.production + echo "REACT_APP_LOCAL_API_URL=${{ secrets.REACT_APP_LOCAL_API_URL }}" >> .env.production - name: Zip artifact for deployment - run: zip release.zip ./* -r + run: zip -r release.zip build .env.production - name: Upload artifact for deployment job - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v2 with: name: node-app path: release.zip @@ -40,34 +51,18 @@ jobs: name: 'Production' url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} permissions: - id-token: write #This is required for requesting the JWT + id-token: write steps: - name: Download artifact from build job - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v2 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_8D61FDF6CC7E404A98BC96270945C9F7 }} - tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_D0F9FEB8912341D0A5A96465DB76B94E }} - subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_4B37E3B0B485419C98F491DEA14A2506 }} - - - name: Set environment variables - run: | - echo "REACT_APP_GOOGLE_MAPS_API_KEY=${{ secrets.REACT_APP_GOOGLE_MAPS_API_KEY }}" >> $GITHUB_ENV - echo "TRIPADVISOR_API_KEY_ENV=${{ secrets.TRIPADVISOR_API_KEY_ENV }}" >> $GITHUB_ENV - echo "DUFFEL_API_KEY_ENV=${{ secrets.DUFFEL_API_KEY_ENV }}" >> $GITHUB_ENV - echo "OAG_API_KEY_ENV=${{ secrets.OAG_API_KEY_ENV }}" >> $GITHUB_ENV - echo "REACT_APP_LOCAL_API_URL=${{ secrets.REACT_APP_LOCAL_API_URL }}" >> $GITHUB_ENV - name: 'Deploy to Azure Web App' - id: deploy-to-webapp uses: azure/webapps-deploy@v2 with: app-name: 'slipspace'