Skip to content

Commit

Permalink
Backend Workflow test #20
Browse files Browse the repository at this point in the history
  • Loading branch information
JancoEngelbrecht committed Sep 12, 2024
1 parent 0f447d7 commit 454021e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
78 changes: 40 additions & 38 deletions .github/workflows/azure-static-web-apps-proud-desert-0a59d0b03.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,48 @@ jobs:
REACT_APP_AUTH_DOMAIN: ${{ secrets.REACT_APP_AUTH_DOMAIN }}
REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL }}

# Backend job (build and deploy only if changes are in the backend directory)
build_and_deploy_backend:
if: contains(github.event.head_commit.message, 'backend')
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
if: contains(github.event.head_commit.message, 'backend')
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '20.x'

- 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
working-directory: ./backend

- name: npm install, build, and test
run: |
npm install
working-directory: ./backend

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: ./backend
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: ./backend

# Deployment job
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'Lagunabutchery'
slot-name: 'Production'
package: .
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_D138B90A0ED54115975467244D32F7EC }}
runs-on: ubuntu-latest
needs: build_and_deploy_backend # Ensure this points to the correct build job
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'Lagunabutchery'
slot-name: 'Production'
package: .
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_D138B90A0ED54115975467244D32F7EC }}
3 changes: 1 addition & 2 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ mongoose.connect(process.env.DB_URI, {
const port = process.env.PORT || 4000; // Set the port from environment variables or default to 4000
const server = app.listen(port, () => {
console.log(`Server is running on ${port}`);
});

});

0 comments on commit 454021e

Please sign in to comment.