diff --git a/.github/pr-title-checker-config.json b/.github/pr-title-checker-config.json new file mode 100644 index 0000000..55e5839 --- /dev/null +++ b/.github/pr-title-checker-config.json @@ -0,0 +1,28 @@ +{ + "LABEL": { + "name": "titulo está fora do padrão", + "color": "FF0000" + }, + "CHECKS": { + "prefixes": [ + "fix: ", + "feat: ", + "test: ", + "style: ", + "revert: ", + "refactor: ", + "perf: ", + "docs: ", + "ci:", + "chore: ", + "build: " + + ], + "regexp": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([a-z-0-9]+\\))?: [\\w-\\[\\] ]+$" + }, + "MESSAGES": { + "success": "Tudo OK", + "failure": "Problema com o padrão do commit", + "notice": "" + } +} \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b4c5e5..f6959de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,8 +10,20 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - + + - name: Checkout code from PR (Safe Checkout) + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Validate PR + uses: thehanimo/pr-title-checker@v1.4.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + remote_configuration_path: "https://raw.githubusercontent.com/leoviana00/lab-k8s-prep-cks/main/.github/pr-title-checker-config.json" + + # - uses: actions/checkout@v2 + - name: Issue Validator uses: HarshCasper/validate-issues-over-pull-requests@v0.1.1 id: validator diff --git a/SECURITY.md b/SECURITY.md index 68fe56e..416b31e 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,4 +2,4 @@ ## Reporting a Vulnerability -**11** \ No newline at end of file +**2** \ No newline at end of file diff --git a/main.yml b/main.yml new file mode 100644 index 0000000..c3cc08b --- /dev/null +++ b/main.yml @@ -0,0 +1,66 @@ +name: "PR Checker" +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + validate-and-comment: + permissions: write-all + runs-on: ubuntu-latest + + steps: + - name: Checkout code from PR (Safe Checkout) + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Validate PR + uses: thehanimo/pr-title-checker@v1.4.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + remote_configuration_path: "https://raw.githubusercontent.com/leoviana00/GitContributionOpenSource/main/.github/pr-title-checker-config.json" + + - name: Comment PR on Success and Add Label [automerge] + if: success() + run: | + AUTHOR_NAME=${{ github.event.pull_request.user.login }} + cat < message.txt + Aí sim hein $AUTHOR_NAME ! Seu PR foi aprovado 🥳 + Faremos o merge aqui em breve. Muito obrigado pela contribuição 🚀 + EOT + + gh pr comment ${{ github.event.pull_request.number }} --body-file=message.txt + gh pr edit ${{ github.event.pull_request.number }} --add-label "automerge" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment PR on Failure + if: failure() + run: | + AUTHOR_NAME=${{ github.event.pull_request.user.login }} + cat < message.txt + Olá $AUTHOR_NAME ! Parece que houve um problema com o seu PR 🧐 Aqui estão algumas coisas para verificar: + + - Seu PR deve seguir a [convenção de commits](https://www.conventionalcommits.org/pt-br/v1.0.0-beta.4/). + + Agradecemos sua contribuição e compreensão 👊😉 + EOT + + gh pr comment ${{ github.event.pull_request.number }} --body-file=message.txt + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + automerge: + runs-on: ubuntu-latest + needs: validate-and-comment + permissions: + contents: write + steps: + - id: automerge + name: automerge + uses: "pascalgn/automerge-action@v0.16.3" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file