Skip to content

Commit 8e481c9

Browse files
committed
chore: Add configuration for act and update .gitignore
- Created a new `.actrc` file for act configuration, specifying container architecture and environment variable usage for secrets. - Updated `.gitignore` to include test results, act-related files, and other temporary files to prevent them from being tracked.
1 parent 1edc31e commit 8e481c9

File tree

15 files changed

+682
-244
lines changed

15 files changed

+682
-244
lines changed

.actrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Configuration for act
2+
--container-architecture linux/amd64
3+
# Use environment variables for secrets instead of a file

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Description
2+
3+
<!-- Describe the changes introduced by this PR -->
4+
5+
## Type of Change
6+
7+
<!-- Mark with an `x` all the checkboxes that apply -->
8+
9+
- [ ] 🐛 Bug fix
10+
- [ ] ✨ New feature
11+
- [ ] 🛠️ Refactoring
12+
- [ ] 📝 Documentation update
13+
- [ ] ⚡ Performance improvement
14+
- [ ] 🧪 Test changes
15+
- [ ] 🔄 CI/CD changes
16+
17+
## Preview Deployment
18+
19+
<!-- When this PR is submitted, a Vercel preview deployment will be automatically created. -->
20+
21+
Preview: <!-- Will be filled automatically when Vercel creates the preview deployment -->
22+
23+
## Screenshot (if applicable)
24+
25+
<!-- Add screenshots if changes include UI updates -->
26+
27+
## How to Test
28+
29+
<!-- Instructions for reviewers to test these changes -->
30+
31+
## Checklist
32+
33+
- [ ] My code follows the style guidelines of this project
34+
- [ ] I have performed a self-review of my own code
35+
- [ ] I have commented my code, particularly in hard-to-understand areas
36+
- [ ] I have made corresponding changes to the documentation
37+
- [ ] My changes generate no new warnings
38+
- [ ] I have added tests that prove my fix is effective or that my feature works
39+
- [ ] New and existing unit tests pass locally with my changes

.github/workflows/CD.yml

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,19 @@
1-
name: Deploy to GitHub Pages
1+
name: Deploy to GitHub Pages (DEPRECATED - See vercel.yml)
22

33
on:
4-
push:
5-
branches: [main]
4+
# Removed automatic triggers
5+
workflow_dispatch:
66

7+
# Note: This workflow is deprecated and has been replaced by the Vercel deployment workflow
8+
# See vercel.yml for the active deployment workflow
9+
# IMPORTANT: This workflow will not be supported after GitHub Actions changes in 2025
710
jobs:
811
deploy:
912
runs-on: ubuntu-latest
1013
permissions:
11-
contents: write # Needed to push to gh-pages branch
14+
contents: read
1215
steps:
13-
- uses: actions/checkout@v4
14-
15-
- name: Use Node.js 20.x
16-
uses: actions/setup-node@v4
17-
with:
18-
node-version: 20
19-
20-
- name: Install pnpm
21-
run: npm install -g pnpm
22-
23-
- name: Install dependencies
24-
run: pnpm install
25-
26-
- name: Build and export
16+
- name: Deployment Placeholder
2717
run: |
28-
pnpm build
29-
pnpm run export
30-
31-
- name: Deploy to GitHub Pages
32-
uses: peaceiris/actions-gh-pages@v4
33-
with:
34-
github_token: ${{ secrets.GITHUB_TOKEN }}
35-
publish_dir: ./out
18+
echo "This workflow is deprecated. Please use the Vercel workflow instead."
19+
echo "See .github/workflows/vercel.yml for production deployments."

.github/workflows/CI.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
permissions:
1313
contents: read # Needed to checkout the repository
14+
pull-requests: write # Needed for PR comments
15+
deployments: write # Needed for GitHub deployments
1416
env: # Add job-level env vars
1517
ACTIONS_RUNNER_DEBUG: true
1618
ACTIONS_STEP_DEBUG: true
@@ -22,25 +24,28 @@ jobs:
2224
echo "VERCEL value: $VERCEL"
2325
2426
- name: Install pnpm
25-
run: npm install -g pnpm
27+
uses: pnpm/action-setup@v3
28+
with:
29+
version: 10
30+
run_install: false
2631

2732
- name: Use Node.js 20.x
2833
uses: actions/setup-node@v4
2934
with:
3035
node-version: 20
3136
cache: "pnpm"
3237

33-
# Setup .next/cache directory cache
38+
# Setup .next/cache directory cache with 2025-compatible approach
3439
- name: Setup Next.js cache
3540
uses: actions/cache@v4
3641
with:
3742
path: |
3843
.next/cache
3944
${{ github.workspace }}/.next/cache
40-
key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
45+
key: ${{ runner.os }}-${{ runner.arch }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
4146
restore-keys: |
42-
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
43-
${{ runner.os }}-nextjs-
47+
${{ runner.os }}-${{ runner.arch }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
48+
${{ runner.os }}-${{ runner.arch }}-nextjs-
4449
4550
- name: Install dependencies
4651
run: pnpm install
@@ -75,3 +80,17 @@ jobs:
7580

7681
- name: Run Playwright e2e tests
7782
run: pnpm test:e2e
83+
84+
# Create a Vercel preview deployment for PR using modern 2025 approach
85+
- name: Deploy Preview to Vercel
86+
if: github.event_name == 'pull_request'
87+
uses: BetaHuhn/deploy-to-vercel-action@v1
88+
with:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
91+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
92+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
93+
PRODUCTION: false
94+
DEPLOY_PR_FROM_FORK: false
95+
CREATE_COMMENT: true
96+
GITHUB_DEPLOYMENT: true

.github/workflows/deploy.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
name: Deploy to GitHub Pages
1+
name: Deploy to GitHub Pages (DEPRECATED - See vercel.yml)
22

33
on:
4-
push:
5-
branches: [main]
4+
# Removed automatic triggers
65
workflow_dispatch:
76

87
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
@@ -16,6 +15,9 @@ concurrency:
1615
group: "pages"
1716
cancel-in-progress: true
1817

18+
# Note: This workflow is deprecated and has been replaced by the Vercel deployment workflow
19+
# See vercel.yml for the active deployment workflow
20+
# IMPORTANT: This workflow will not be supported after GitHub Actions changes in 2025
1921
jobs:
2022
build:
2123
runs-on: ubuntu-latest
@@ -46,13 +48,14 @@ jobs:
4648
with:
4749
path: ./out
4850

51+
# Deploy job is deprecated - using Vercel deployment instead
4952
deploy:
50-
environment:
51-
name: github-pages
52-
url: ${{ steps.deployment.outputs.page_url }}
5353
runs-on: ubuntu-latest
5454
needs: build
5555
steps:
56-
- name: Deploy to GitHub Pages
57-
id: deployment
58-
uses: actions/deploy-pages@v4
56+
- name: Deployment Placeholder
57+
run: |
58+
echo "This workflow is deprecated. Please use the Vercel workflow instead."
59+
echo "See .github/workflows/vercel.yml for production deployments."
60+
echo "This workflow is deprecated. Please use the Vercel workflow instead."
61+
echo "See .github/workflows/vercel.yml for production deployments."

.github/workflows/vercel.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Deploy to Vercel
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
deployments: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v3
20+
with:
21+
version: 10
22+
run_install: false
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: "20"
28+
cache: "pnpm"
29+
30+
# Setup .next/cache directory cache with 2025-compatible approach
31+
- name: Setup Next.js cache
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
.next/cache
36+
${{ github.workspace }}/.next/cache
37+
key: ${{ runner.os }}-${{ runner.arch }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
38+
restore-keys: |
39+
${{ runner.os }}-${{ runner.arch }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
40+
${{ runner.os }}-${{ runner.arch }}-nextjs-
41+
42+
- name: Install dependencies
43+
run: pnpm install
44+
45+
- name: Lint
46+
run: pnpm lint
47+
48+
- name: Build
49+
run: pnpm build
50+
env:
51+
NEXT_TELEMETRY_DISABLED: 1
52+
53+
# Install Vercel CLI
54+
- name: Install Vercel CLI
55+
run: npm install -g vercel
56+
57+
# Deploy to Vercel following their official guidance
58+
- name: Deploy to Vercel (Production)
59+
run: |
60+
echo "Deploying to Vercel..."
61+
62+
# Create project.json for Vercel CLI
63+
mkdir -p .vercel
64+
echo '{
65+
"projectId": "${{ secrets.VERCEL_PROJECT_ID }}",
66+
"orgId": "${{ secrets.VERCEL_ORG_ID }}"
67+
}' > .vercel/project.json
68+
69+
# Deploy to Vercel using project linking
70+
vercel --prod --token=${{ secrets.VERCEL_TOKEN }} --yes
71+
72+
# Add custom domains after deployment
73+
vercel domains add csvdatavalidator.fabien.dev --token=${{ secrets.VERCEL_TOKEN }} --yes
74+
vercel domains add csvvalidator.fabien.dev --token=${{ secrets.VERCEL_TOKEN }} --yes
75+
env:
76+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
77+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ lib-cov
2323
coverage
2424
*.lcov
2525

26+
# Test results and reports
27+
playwright-report/
28+
test-results/
29+
2630
# nyc test coverage
2731
.nyc_output
2832

@@ -119,3 +123,10 @@ LocalCsvDataValidator/
119123

120124
csv
121125
.vercel
126+
.secrets
127+
128+
# Act testing files
129+
act-secrets.sh
130+
act.md
131+
.github/workflows/test-events/
132+
.act-secrets

README.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![TypeScript](https://img.shields.io/badge/TypeScript-5+-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)
55
[![Ajv](https://img.shields.io/badge/Validation-Ajv-orange?style=flat-square)](https://ajv.js.org/)
66
[![UI](https://img.shields.io/badge/UI-Shadcn/ui-black?style=flat-square)](https://ui.shadcn.com/)
7-
[![CI Status](https://github.com/FabienDostieIT/CSV_Data_Validator/actions/workflows/CI.yml/badge.svg)](https://github.com/FabienDostieIT/CSV_Data_Validator/actions/workflows/CI.yml)
7+
[![CI Status](https://github.com/fabiendostie/CSV_Data_Validator/actions/workflows/CI.yml/badge.svg)](https://github.com/fabiendostie/CSV_Data_Validator/actions/workflows/CI.yml)
88

99
A modern, browser-based tool for validating, editing, and ensuring compliance of CSV data against predefined or custom JSON schemas. Built with Next.js, TypeScript, and Shadcn/ui.
1010

@@ -106,9 +106,61 @@ pnpm e2e
106106

107107
- **CI (`.github/workflows/CI.yml`):** Runs automatically on pushes/PRs to `main` and `develop`. Includes lint, format check, full tests (`pnpm test`), build, and E2E tests.
108108
- **CodeQL (`.github/workflows/codeql-analysis.yml`):** Performs security analysis.
109-
- **CD (`.github/workflows/CD.yml`):** Deploys the static export to GitHub Pages from the `main` branch.
110-
- **Static Export:** Generated via `pnpm build && pnpm run export` (outputs to `./out`).
111-
- **GitHub Pages:** Configure repo settings to serve from the `gh-pages` branch.
109+
- **Vercel Deployment (`.github/workflows/vercel.yml`):** Deploys the application to Vercel from the `main` branch using `BetaHuhn/deploy-to-vercel-action@v1`.
110+
- **Preview Deployments:** Automatically creates preview deployments for pull requests with PR comments showing deployment URLs.
111+
- **Vercel Configuration:** Uses `vercel.json` to define build settings and other configuration.
112+
- **2025 Compatibility:** All workflows are updated to use the latest GitHub Actions (v4+) and include the 2025-compatible cache keys that will remain functional after the April 2025 GitHub cache service changes.
113+
114+
### Setting up Vercel Deployment
115+
116+
To set up deployments to Vercel, you need to add the following secrets to your GitHub repository:
117+
118+
1. `VERCEL_TOKEN`: Your Vercel API token
119+
2. `VERCEL_PROJECT_ID`: Your Vercel project ID
120+
3. `VERCEL_ORG_ID`: Your Vercel organization ID
121+
4. `GITHUB_TOKEN`: Automatically provided by GitHub Actions
122+
123+
You can obtain the Vercel values from the Vercel dashboard or by running:
124+
125+
```bash
126+
vercel link
127+
```
128+
129+
These secrets are required for both the production deployment workflow (`vercel.yml`) and the preview deployments in the CI workflow.
130+
131+
### Testing GitHub Actions Locally
132+
133+
This project includes tools to test GitHub Actions workflows locally before pushing changes to GitHub:
134+
135+
1. Install [act](https://github.com/nektos/act) if you haven't already:
136+
137+
```bash
138+
# Linux/macOS with Homebrew
139+
brew install act
140+
141+
# Or with npm
142+
npm install -g @nektos/act
143+
```
144+
145+
2. Use the provided script to securely test workflows:
146+
147+
```bash
148+
# Source the script to load the function
149+
source act-secrets.sh
150+
151+
# Test the Vercel deployment workflow
152+
run_act_workflow .github/workflows/vercel.yml push
153+
154+
# Test the CI workflow with PR preview
155+
run_act_workflow .github/workflows/CI.yml pull_request
156+
```
157+
158+
The script will prompt for your GitHub and Vercel credentials, which are never stored on disk and only kept in memory during the test.
159+
160+
You'll need to create:
161+
162+
- A [GitHub Personal Access Token](https://github.com/settings/tokens) with `repo` scope
163+
- Vercel credentials as mentioned in the deployment section
112164

113165
---
114166

0 commit comments

Comments
 (0)