Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/test-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Test Images action
on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: write

jobs:
test:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Project
run: |
rm -rf image-project
mkdir -p image-project
cd image-project
# No package.json needed for a simple image test, but let's add one to be safe
echo '{"name": "image-project"}' > package.json
# Create a dummy SVG
echo '<svg><rect x="0" y="0" width="10" height="10" fill="red"/></svg>' > test.svg
# Create a dummy PNG
echo 'dummy png' > test.png
# Create a dummy GIF
echo 'dummy gif' > test.gif

- name: Detect Node.js version and package manager
shell: bash
id: detect_env
run: node "dist/detect-env.js"

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ steps.detect_env.outputs.node_version }}

- name: Install dependencies (Direct Test)
run: |
if command -v apt-get >/dev/null; then
sudo apt-get update && sudo apt-get install -y optipng jpegoptim gifsicle
fi

- name: Run image optimization (Direct Test)
run: |
cd image-project
echo "Optimizing SVGs..."
npx svgo -r . || true
echo "Optimizing PNGs..."
find . -name "*.png" -exec optipng -o2 {} + || true
echo "Optimizing GIFs..."
find . -name "*.gif" -exec gifsicle -O3 --batch {} + || true
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ This file provides context and instructions for AI agents working on the @area44

## Project Overview

This repository contains reusable GitHub Actions workflows and composite actions (Astro, Vite, Lint/Format) for the AREA44 ecosystem.
This repository contains reusable GitHub Actions workflows and composite actions (Astro, Vite, Lint/Format, Images) for the AREA44 ecosystem.

## Core Directives

- **ES Modules**: The project is configured as an ES module (`"type": "module"` in `package.json`). Build artifacts in `dist/` are also generated as ESM.
- **Tracked Build Artifacts**: The `dist/` folder is tracked in the repository to allow composite actions to be used directly without a build step in consuming workflows.
- **Clean Distribution**: The `dist/` directory must only contain final bundled JavaScript files. Do not include source files or redundant artifacts.
- **Compatibility**: Preserve original `action.yml` files in root directories (astro/, autofix/, lint-format/, vite/) and maintain original public inputs/outputs for backward compatibility.
- **Compatibility**: Preserve original `action.yml` files in root directories (astro/, lint-format/, images/, vite/) and maintain original public inputs/outputs for backward compatibility.
- **No Shared Chunks**: `rolldown.config.mjs` uses separate configurations for each entry point to prevent shared chunks that cause "require" errors in ESM-based GitHub Actions runners.

## Development & Build
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ This repository contains reusable **GitHub Actions workflows and composite actio

- **[Astro](./astro/README.md)**: Build and deploy Astro sites.
- **[Vite](./vite/README.md)**: Build and deploy Vite sites.
- **[Lint/Format](./lint-format/README.md)**: Run lint/format scripts and integrate with autofix.ci.
- **[Lint/Format](./lint-format/README.md)**: Run lint/format scripts.
- **[Images](./images/README.md)**: Optimize images (SVGs, PNGs, JPEGs).

## License

Expand Down
28 changes: 0 additions & 28 deletions autofix/README.md

This file was deleted.

95 changes: 0 additions & 95 deletions autofix/action.yml

This file was deleted.

41 changes: 41 additions & 0 deletions images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# area44/images

This composite action optimizes images (SVGs, PNGs, JPEGs, and GIFs).

## Usage

Create a workflow file (e.g., `.github/workflows/images.yml`) in your repository:

```yaml
name: images.ci

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: write

jobs:
optimize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: area44/workflows/images@main
```

## Inputs

| Input | Description | Required | Default |
| -------------- | -------------------------------------------------------- | -------- | ---------------------------------------- |
| `node-version` | Optional Node.js version override (e.g., '24', 'lts/\*') | No | Detected from `.nvmrc` or `package.json` |

## Tools Used

- **SVGO**: For SVG optimization.
- **OptiPNG**: For PNG optimization.
- **Jpegoptim**: For JPEG optimization.
- **Gifsicle**: For GIF optimization.
- **autofix.ci**: For automatically committing the optimized images.
63 changes: 63 additions & 0 deletions images/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: area44/images
description: Optimize images
inputs:
node-version:
description: "Optional Node.js version override"
required: false

runs:
using: "composite"
steps:
- name: Detect Node.js version and package manager
shell: bash
id: detect_env
run: node "${GITHUB_ACTION_PATH}/../dist/detect-env.js"

- name: Setup PNPM
if: ${{ steps.detect_env.outputs.package_manager == 'pnpm' }}
uses: pnpm/action-setup@v5
with:
version: ${{ steps.detect_env.outputs.package_manager_version }}

- name: Setup Bun
if: ${{ steps.detect_env.outputs.package_manager == 'bun' }}
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ steps.detect_env.outputs.package_manager_version }}

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version || steps.detect_env.outputs.node_version }}
cache: ${{ steps.detect_env.outputs.package_manager != 'bun' && steps.detect_env.outputs.package_manager || '' }}
cache-dependency-path: |
**/package-lock.json
**/pnpm-lock.yaml
**/yarn.lock
**/bun.lock
**/bun.lockb

- name: Install dependencies
shell: bash
run: |
if command -v apt-get >/dev/null; then
sudo apt-get update && sudo apt-get install -y optipng jpegoptim gifsicle
fi

- name: Optimize Images
shell: bash
run: |
echo "Optimizing SVGs..."
npx svgo -r . || true

echo "Optimizing PNGs..."
find . -name "*.png" -not -path "./node_modules/*" -exec optipng -o2 {} + || true

echo "Optimizing JPEGs..."
find . \( -name "*.jpg" -o -name "*.jpeg" \) -not -path "./node_modules/*" -exec jpegoptim --strip-all {} + || true

echo "Optimizing GIFs..."
find . -name "*.gif" -not -path "./node_modules/*" -exec gifsicle -O3 --batch {} + || true

- name: Run autofix.ci
uses: autofix-ci/action@v1
4 changes: 2 additions & 2 deletions lint-format/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# area44/lint-format

Run linting/formatting scripts and push fixes using autofix.ci.
Run linting/formatting scripts.

## Usage

```yaml
name: autofix.ci
name: Lint/Format
on:
push:
branches: ["main"]
Expand Down
Loading