From 5275f12b3d6624a9e4eb35506ae0e0a0abed2ba1 Mon Sep 17 00:00:00 2001 From: Raissa Brizeno Date: Fri, 9 Aug 2024 18:47:25 -0300 Subject: [PATCH] Update github-actions-demo.yml --- workflows/github-actions-demo.yml | 39 +++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/workflows/github-actions-demo.yml b/workflows/github-actions-demo.yml index ac5c31c..8389947 100644 --- a/workflows/github-actions-demo.yml +++ b/workflows/github-actions-demo.yml @@ -9,40 +9,65 @@ on: jobs: build: + # executar comandos em um subdiretório runs-on: ubuntu-latest defaults: run: working-directory: ./exercicios/para-sala/users-api-aula + # configuração do ambiente de execução do projeto Node.js strategy: matrix: node-version: [18.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: + # clone do repositório - name: checkout uses: actions/checkout@v4 + # pega a versão declarada do Node.j e configura no ambiente virtual - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + # instala dependencias e roda os testes - run: npm ci - run: npm run build --if-present - run: npm test - - - name: Login to Docker Hub - uses: docker/login-action@v2 + + # lint para garantir que o código segue os padrões definidos + - name: Run ESLint + run: npm run lint + + # verificação de vulnerabilidades em pacotes + - name: Run security audit + run: npm audit + + # conferir se tem erros de tipagem + - name: TypeScript Check + run: npx tsc --noEmit + + # setamos o Docker Buildx no ambiente onde o job está sendo executado. + # Permite construir imagens Docker para várias arquiteturas + - name: Set up Docker Buildx + if: github.ref == 'refs/heads/main' + uses: docker/setup-buildx-action@v3 + + # faz login no docker hub + - name: Log in to Docker Hub + if: github.ref == 'refs/heads/main' + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_LOGIN }} + username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: Build and push + if: github.ref == 'refs/heads/main' uses: docker/build-push-action@v4 with: context: exercicios/para-sala/users-api-aula push: true tags: raissabrizeno/users-api-aula:1.0.0 - - +