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
on: | |
push: | |
branches: | |
- "main" | |
env: | |
AZURE_FUNCTIONAPP_NAME: "githubactions-xxx-xxx" # For Oppgave 8: Sett inn navn på din egen Azure function app | |
AZURE_FUNCTIONAPP_PACKAGE_PATH: "." # Function app path (denne trenger du ikke endre) | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Sjekk ut koden" | |
uses: actions/checkout@v4 | |
# Oppgave 3: Sette opp riktig node versjon før bygging | |
- name: Setup Node Environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
# Oppgave 4: Installere dependencies | |
- name: npm install | |
run: npm ci | |
# Oppgave 5: Kjører testene i prosjektet. Feiler jobben dersom tester feiler. | |
- name: Run tests | |
run: npm test | |
# Oppgave 6: List ut npm dependencies med sårbarheter. | |
- name: Audit packages | |
run: npm audit fix --force | |
# Oppgave 7: Kjør linting | |
- name: Run lint (eslint) | |
run: npm run lint | |
# Oppgave 8: Deploy step, sett navnet på din function app, i env.AZURE_FUNCTIONAPP_NAME | |
# Og legg publish profile i en Github secret med navn AZURE_FUNCTIONAPP_PUBLISH_PROFILE | |
#- name: "Deploy til Azure Functions app" | |
# uses: Azure/functions-action@v1 | |
# with: | |
# app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }} | |
# package: "${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}" | |
# publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} | |
# Lag fint testresultat i github actions | |
- name: Publish Test Summary Results | |
run: npx github-actions-ctrf ctrf/ctrf-report.json |