Vamos #72
This file contains hidden or 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
name: CI-CD | |
on: | |
push: | |
branches: ["main", "desenvolvimento"] | |
workflow_dispatch: | |
jobs: | |
CI: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
security-events: write | |
actions: read | |
steps: | |
- name: Obtendo o código fonte | |
uses: actions/[email protected] | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: 18.x | |
- name: Instalação de dependencias | |
run: npm install | |
working-directory: ./src | |
- name: Execução de Teste Unitário | |
run: npm test | |
working-directory: ./src | |
- name: Docker Login | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USR }} | |
password: ${{ secrets.DOCKERHUB_PWD }} | |
- name: Docker build | |
uses: docker/[email protected] | |
with: | |
context: ./src | |
file: ./src/Dockerfile | |
push: true | |
tags: | | |
fabricioveronez/conversao-temperatura:v${{ github.run_number }} | |
fabricioveronez/conversao-temperatura:latest | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/[email protected] | |
with: | |
image-ref: fabricioveronez/conversao-temperatura:v${{ github.run_number }} | |
format: 'sarif' | |
output: 'trivy-results.sarif' | |
exit-code: 0 | |
severity: UNKNOWN,CRITICAL,HIGH,MEDIUM,LOW | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: 'trivy-results.sarif' | |