schweigenderFlugel / portfolio

Link to my portfolio website
https://facu-castro.netlify.app/
0 stars 0 forks source link

Create a workflow for deployment en netlify. #9

Closed schweigenderFlugel closed 3 months ago

schweigenderFlugel commented 4 months ago
name: Deployment

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
    types: 
      - closed

jobs:
  deployment:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-22.04

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 18

      - name: Install dependencies
        run: npm install --force --no-audit --no-fund --no-optional

      - name: Lint
        run: npm run lint

      - name: Cypress Tests
        uses: cypress-io/github-action@v6
        with:
          # Don't forget to change the port to 9000 when the astro app starts
          install-command: npm install --force 
          start: npm run start
          wait-on: http://localhost:9000
          parallel: true
          record: true
        env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
           CYPRESS_PROJECT_ID: ${{ secrets.PROJECT_ID }}

      - name: Deploy to Netlify
        run: curl -X POST -d {} ${{ secrets.NETLIFY_BUILD_HOOK }}

      - name: Run k6 cloud test
        uses: k6io/action@v0.1
        with:
          filename: test.js
          cloud: true
          token: ${{ secrets.K6_CLOUD_API_TOKEN }}
schweigenderFlugel commented 3 months ago

The end of the code includes the step for perfornance test, but the trigger for k6 cloud testing by using de k6.exe file on local. In order to trigger the last step, netlify must notify GitHub Actions that the deployment was successful.

https://api.github.com/repos/schweigenderFlugel/portfolio/dispatches

Content-Type: application/json Authorization: GITHUB_TOKEN

{ "event-type": "netlify-deploy-complete" }