Skip to content

Commit

Permalink
Fixed codestyle workflow (#271)
Browse files Browse the repository at this point in the history
* feat: add dependencias entre workflows e ajust code-style7

* fix: removendo dependencias de workflows

* ajust workflows

* add setup env script

* change name to base fowflows

* add code owners

* add code owners

* ajust codewoners

---------

Co-authored-by: Alexandre Gomes <[email protected]>
  • Loading branch information
PiluVitu and Alecell committed Sep 3, 2024
1 parent bc4dc91 commit e005f53
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 58 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @devhatt/hatts @devhatt/petdex-frontend-administrators
21 changes: 0 additions & 21 deletions .github/workflows/autoAssigned.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/base-workflows.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 4 additions & 36 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 30 additions & 0 deletions setup.mjs
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit e005f53

Please sign in to comment.