Skip to content

Commit eef2352

Browse files
authored
Merge pull request #31 from MewenLeHo/main-mlh-full-update-repository
Full update repository
2 parents 07b3c3d + 509c603 commit eef2352

File tree

9 files changed

+3897
-479
lines changed

9 files changed

+3897
-479
lines changed

.github/workflows/lint-minify.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Lint and Minify JavaScript
2+
3+
# Trigger the workflow only on pushes to the main branch,
4+
# ignoring pushes that only affect the minified file.
5+
on:
6+
push:
7+
branches:
8+
- main
9+
paths-ignore:
10+
- 'detectAutocomplete.min.js'
11+
12+
jobs:
13+
lint:
14+
name: Lint JavaScript
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
# Step 1: Checkout the repository code
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
# Step 2: Set up Node.js environment
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
28+
# Step 3: Install project dependencies
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
# Step 4: Run ESLint on the source file
33+
- name: Run ESLint
34+
run: npx eslint detectAutocomplete.js
35+
36+
minify:
37+
name: Minify and Commit JavaScript
38+
runs-on: ubuntu-latest
39+
needs: lint # Ensure minification runs only after linting succeeds
40+
if: ${{ !contains(github.event.head_commit.message, '[auto]') }} # Skip if it's an automated commit
41+
42+
steps:
43+
# Step 1: Checkout the repository with write access
44+
- name: Checkout repository (with write access)
45+
uses: actions/checkout@v4
46+
with:
47+
token: ${{ secrets.GITHUB_TOKEN }}
48+
49+
# Step 2: Set up Node.js environment
50+
- name: Set up Node.js
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: '20'
54+
55+
# Step 3: Install project dependencies
56+
- name: Install dependencies
57+
run: npm ci
58+
59+
# Step 4: Minify the JavaScript source file
60+
- name: Minify JavaScript
61+
run: |
62+
npx terser detectAutocomplete.js --compress --mangle -o detectAutocomplete.min.js
63+
64+
# Step 5: Commit the minified file if there are changes
65+
- name: Commit minified file if changed
66+
run: |
67+
git config --local user.name "GitHub Actions"
68+
git config --local user.email "actions@github.com"
69+
git add detectAutocomplete.min.js
70+
if git diff --cached --quiet; then
71+
echo "No changes to commit."
72+
else
73+
git commit -m "Minify JavaScript file [auto]"
74+
git push

.github/workflows/minify.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Create Release
2+
3+
# Trigger the workflow only when a tag starting with "v" is pushed
4+
on:
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
jobs:
10+
release:
11+
name: Create GitHub Release
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# Step 1: Checkout the repository code at the tagged commit
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
# Step 2: Create a GitHub release and attach the minified file
20+
- name: Create GitHub release
21+
uses: softprops/action-gh-release@v2
22+
with:
23+
files: detectAutocomplete.min.js

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Dependency directories
2+
node_modules/
3+
dist/
4+
build/
5+
6+
# Logs
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
11+
# Editor folders
12+
.vscode/
13+
.idea/
14+
15+
# Minified and source map files
16+
*.min.js
17+
*.map
18+
19+
# Test coverage
20+
coverage/
21+
22+
# Environment variables
23+
.env
24+
.env.local
25+
.env.*.local
26+
27+
# OS generated files
28+
.DS_Store
29+
Thumbs.db
30+
31+
# System files
32+
*.swp
33+
*.swo

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
A simple tool for validating the `autocomplete` attributes of HTML form elements according to the HTML specification.
44

5+
## CI/CD Status
6+
7+
### Workflows
8+
[![Lint and Minify workflow](https://github.com/MewenLeHo/detectAutocomplete/actions/workflows/lint-minify.yml/badge.svg)](https://github.com//MewenLeHo/detectAutocomplete/actions/workflows/lint-minify.yml)
9+
[![Release workflow](https://github.com//MewenLeHo/detectAutocomplete/actions/workflows/release.yml/badge.svg)](https://github.com//MewenLeHo/detectAutocomplete/actions/workflows/release.yml)
10+
11+
### Latest Release
12+
[![Latest Release](https://img.shields.io/github/v/release//MewenLeHo/detectAutocomplete?label=latest&style=flat)](https://github.com//MewenLeHo/detectAutocomplete/releases/latest)
13+
514
## Demo
615

716
[Check out the demo](https://mewenleho.github.io/detectAutocomplete/)

0 commit comments

Comments
 (0)