diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..00b0c9dd --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @devhatt/hatts @devhatt/petdex-frontend-administrators diff --git a/.github/workflows/autoAssigned.yml b/.github/workflows/autoAssigned.yml deleted file mode 100644 index f388bcb2..00000000 --- a/.github/workflows/autoAssigned.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Auto-assign on comment - -on: - issue_comment: - types: [created] - -jobs: - auto-assign: - runs-on: ubuntu-latest - steps: - - name: Check for "EU QUERO!!!" comment - if: contains(github.event.comment.body, 'EU QUERO!!!') - run: | - # Extract the commenter's username - commenter=$(jq -r .comment.user.login $GITHUB_EVENT_PATH) - - # Add the commenter as an assignee to the issue using a Personal Access Token - echo "Assigning $commenter to the issue..." - curl -X POST -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ - -d "{\"assignees\": [\"$commenter\"]}" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees" diff --git a/.github/workflows/base-workflows.yml b/.github/workflows/base-workflows.yml new file mode 100644 index 00000000..df126b4a --- /dev/null +++ b/.github/workflows/base-workflows.yml @@ -0,0 +1,11 @@ +name: Base workflows + +on: + issue_comment: + types: [created] + pull_request: + +jobs: + assignes: + uses: devhatt/workflows/.github/workflows/auto-assign.yml@main + secrets: inherit diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0752a3b0..4be2186a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3 - name: Setup deps - uses: ./.github/actions/install-deps + uses: devhatt/workflows/.github/actions/pnpm-setup@main - name: Build run: pnpm build diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 2b731759..d462ec8d 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -17,45 +17,13 @@ jobs: uses: actions/checkout@v3 - name: Setup deps - uses: ./.github/actions/install-deps - - - name: Get all changed files - id: all-changed-files - uses: tj-actions/changed-files@v41 - with: - files: | - !pnpm-lock.yaml + uses: devhatt/workflows/.github/actions/pnpm-setup@main - name: Run prettier in all files - if: steps.all-changed-files.outputs.any_changed == 'true' - env: - files: ${{ steps.all-changed-files.outputs.all_changed_files }} - run: pnpm exec prettier $files --check --ignore-unknown - - - name: Get specific changed files - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files_yaml: | - code: - - '**.js' - - '**.ts' - - '**.tsx' - - '**.jsx' - - '**.mjs' - - '**.cjs' - style: - - '**.scss' + run: pnpm exec prettier . --check --ignore-unknown - name: Run stylelint in scss files - if: steps.changed-files.outputs.style_any_changed == 'true' - env: - files: ${{ steps.changed-files.outputs.style_all_changed_files }} - run: pnpm exec stylelint $files --allow-empty-input + run: pnpm exec stylelint . --allow-empty-input - name: Run eslint in code files - if: steps.changed-files.outputs.code_any_changed == 'true' - env: - files: ${{ steps.changed-files.outputs.code_all_changed_files }} - run: pnpm exec eslint $files --report-unused-disable-directives --max-warnings 0 --output-file eslint_report.json --format json - continue-on-error: true + run: pnpm exec eslint . --report-unused-disable-directives --max-warnings 0 diff --git a/setup.mjs b/setup.mjs new file mode 100644 index 00000000..5398d1e4 --- /dev/null +++ b/setup.mjs @@ -0,0 +1,30 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const envFilePath = path.join(__dirname, '.env'); + +async function setupDotEnv() { + if (fs.existsSync(envFilePath)) { + console.log( + 'O .env já existe, se você deseja recriá-lo, exclua o arquivo e execute este script novamente.', + ); + return; + } + + try { + console.log('Baixando o .env do repositório...'); + const envData = await fetch( + 'https://raw.githubusercontent.com/devhatt/envs/main/petdex-front.env', + ).then((response) => response.text()); + fs.writeFileSync(envFilePath, envData); + console.log('O arquivo .env foi criado com sucesso!'); + } catch (error) { + console.error('Erro ao criar o arquivo .env:', error); + } +} + +setupDotEnv();