diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..5c1d8b2 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,73 @@ +name: Vercel Preview Deployment + +# Variáveis de ambiente para os jobs da Vercel +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + push: + branches: + - develop + pull_request: + branches: [main, develop] + +jobs: + # ----------------------------------------------------------------- + # JOB 1: Testa e Linta o código + # ----------------------------------------------------------------- + test-and-lint: + name: Test & Lint + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [22.x] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "pnpm" + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run linter + run: pnpm run lint + + - name: Run tests + run: pnpm run test:ci + + # ----------------------------------------------------------------- + # JOB 2: Deploy de Preview (Vercel) + # ----------------------------------------------------------------- + deploy-preview: + name: Deploy Preview + needs: test-and-lint + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Project Artifacts to Vercel + # A Vercel CLI detecta o contexto de PR e posta o comentário automaticamente + run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/production.yml similarity index 50% rename from .github/workflows/ci.yml rename to .github/workflows/production.yml index 5f42982..8ad1060 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/production.yml @@ -1,14 +1,18 @@ -name: CI/CD Pipeline com Tagging +name: Vercel Production Deployment and Tagging + +# Variáveis de ambiente para os jobs da Vercel +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} on: push: - branches: [main, develop] - pull_request: - branches: [main, develop] + branches: + - main jobs: # ----------------------------------------------------------------- - # JOB 1: Apenas Testa e Linta + # JOB 1: Testa e Linta o código # ----------------------------------------------------------------- test-and-lint: name: Test & Lint @@ -48,11 +52,6 @@ jobs: name: Deploy to Production needs: test-and-lint runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - deployments: write - if: github.ref == 'refs/heads/main' && github.event_name == 'push' steps: - name: Checkout code @@ -71,62 +70,7 @@ jobs: run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} # ----------------------------------------------------------------- - # JOB 3: Deploy de Preview - # ----------------------------------------------------------------- - deploy-preview: - name: Deploy Preview - needs: test-and-lint - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - deployments: write - if: github.event_name == 'pull_request' || (github.ref == 'refs/heads/develop' && github.event_name == 'push') - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Vercel CLI - run: npm install --global vercel@latest - - - name: Pull Vercel Environment Information - run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - - - name: Build Project Artifacts - run: vercel build --token=${{ secrets.VERCEL_TOKEN }} - - - name: Deploy Project Artifacts to Vercel - run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} - - - name: Get Repo ID - if: github.event_name == 'pull_request' - run: | - REPO_ID=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }} | jq -r .id) - echo "REPO_ID=$REPO_ID" >> $GITHUB_ENV - - - name: Notify Vercel for PR Comment (if PR) - if: github.event_name == 'pull_request' - run: | - curl -X POST "https://api.vercel.com/v13/deployments" \ - -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \ - -H "Content-Type: application/json" \ - -d '{ - "name": "mrdeveloper", - "source": "cli", - "gitSource": { - "type": "github", - "repo": "${{ github.repository }}", - "ref": "${{ github.head_ref }}", - "sha": "${{ github.sha }}", - "repoId": ${{ env.REPO_ID }} - } - }' - - - - # ----------------------------------------------------------------- - # JOB 4: Criar Tag de Versão (Sem mudanças) + # JOB 3: Criar Tag de Versão # ----------------------------------------------------------------- tag-release: name: Tag Release @@ -137,6 +81,9 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + # Necessário para buscar tags existentes + fetch-depth: 0 - name: Get version from package.json id: get_version @@ -145,12 +92,13 @@ jobs: echo "TAG_VERSION=v$VERSION" >> $GITHUB_ENV - name: Check if tag already exists + id: check_tag run: | - if git ls-remote --tags origin | grep -q "refs/tags/${TAG_VERSION}"; then - echo "Tag $TAG_VERSION already exists. Skipping..." + if git rev-parse "refs/tags/${{ env.TAG_VERSION }}" >/dev/null 2>&1; then + echo "Tag ${{ env.TAG_VERSION }} already exists. Skipping..." echo "SKIP_TAG=true" >> $GITHUB_ENV else - echo "Tag $TAG_VERSION does not exist. Proceeding..." + echo "Tag ${{ env.TAG_VERSION }} does not exist. Proceeding..." echo "SKIP_TAG=false" >> $GITHUB_ENV fi @@ -159,5 +107,5 @@ jobs: run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - git tag $TAG_VERSION -m "Release $TAG_VERSION" - git push origin $TAG_VERSION \ No newline at end of file + git tag ${{ env.TAG_VERSION }} -m "Release ${{ env.TAG_VERSION }}" + git push origin ${{ env.TAG_VERSION }} diff --git a/src/App.tsx b/src/App.tsx index e051449..921ecce 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,7 @@ import "./App.scss"; import "./styles/layout.scss"; +import AnimatedBackground from "./components/AnimatedBackground"; import Header from "./components/Header"; import Footer from "./components/Footer"; import Hero from "./sections/Hero"; @@ -11,6 +12,7 @@ import Contact from "./sections/Contact"; const App = () => { return (