diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..c969271 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,41 @@ +name: CD + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run CI + uses: ./.github/workflows/ci.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + deploy: + needs: tests + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: build + path: build + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..943fc6b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: "Testes" + +on: + workflow_call: + +permissions: + contents: read + pages: write + id-token: write + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Instalação Nodejs + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Instalação das dependências + run: npm install + + - name: Executando Testes + run: npm run test + + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.organization=ligtonribeiro + -Dsonar.projectKey=ligtonribeiro_express-api-example + -Dorganization-key=ligtonribeiro + -Dsonar.sources=src + -Dsonar.language=js,ts + -Dsonar.javascript.file.suffixes=.js + -Dsonar.typescript.file.suffixes=.ts + -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info + -Dsonar.sourceEncoding=UTF-8