Skip to content
Merged

v4 #4

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
30 changes: 20 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: test

on:
push:
branches: [master]
branches: [main, master]
workflow_dispatch:

concurrency:
group: pages
cancel-in-progress: true

jobs:
build:
name: Build static site
Expand All @@ -18,15 +22,21 @@ jobs:
cat > pages/index.md <<EOL
Test
EOL
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: pre-installed
extensions: mbstring, fileinfo, gd, imagick, intl, gettext, :redis
- name: Run Action
uses: ./
with:
version: '8.93.1'
config: 'config.yml'
args: '-vv'
install_themes: 'yes'
version: '8.94.3'
options: '-vv'
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
46 changes: 13 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,55 @@
# Cecil build Action

This GitHub Action builds a static site with [_Cecil_](https://cecil.app).
This GitHub Action builds a [_Cecil_](https://cecil.app) site and uploads a GitHub Pages artifact.

[![test](https://github.com/Cecilapp/Action/actions/workflows/test.yml/badge.svg)](https://github.com/Cecilapp/Action/actions/workflows/test.yml)

## Usage

```yaml
- name: Build site
uses: Cecilapp/Cecil-Action@v3
uses: Cecilapp/Cecil-Action@v4
# optional
with:
version: '8.0.0' # default: latest version
config: 'config.yml' # default: ''
args: '-v' # default: '-v'
install_themes: 'yes' # default: 'yes'
version: 8.0.0 # default: latest version
install_themes: "yes" # default: "yes"
options: -v --config=config.yml # default: "-v" (verbose)
```

### Workflow example

The following workflow:

1. runs on pushes to the `master` branch
1. runs on pushes to the `main` and `master` branches
2. checkout source
3. setup PHP
4. downloads Cecil
5. installs theme(s)
6. runs `php cecil.phar build -v`
7. deploys `_site` to GitHub Pages
6. runs Cecil build
7. upload pages artifact
8. deploys to GitHub Pages

```yaml
name: Build and deploy to GitHub Pages
on:
push:
branches: [main] # or [master]
workflow_dispatch: # run manually

branches: [main, master]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: pre-installed
extensions: mbstring, fileinfo, gd, imagick, intl, gettext, :redis

- name: Setup Pages
id: pages
uses: actions/configure-pages@v5

- name: Build site
uses: Cecilapp/Cecil-Action@v3
with:
args: '-v --baseurl="${{ steps.pages.outputs.base_url }}/"'

- name: Upload artifact
uses: actions/upload-pages-artifact@v4

uses: Cecilapp/Cecil-Action@v4
deploy:
needs: build
environment:
Expand All @@ -79,7 +59,7 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v5
```

## License
Expand Down
88 changes: 62 additions & 26 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,81 @@
name: 'Cecil Action'
description: 'Build a Cecil static site.'
author: 'Arnaud Ligny'
inputs:
name: "Cecil Action"
description: "Build a Cecil static site."
author: "Arnaud Ligny"
inputs:
version:
description: 'Cecil version (optional, last version by default).'
config:
description: 'Cecil configuration file (optional, `cecil.yml` by default).'
args:
description: 'Cecil arguments (optionnal, `-v` by default).'
default: '-v'
description: "Cecil version (optional, last version by default)."
install_themes:
description: 'Use "no" to do not install theme(s) (optionnal, `yes` by default).'
default: 'yes'
description: "Set to `no` to skip installing theme(s) (optional, `yes` by default)."
default: "yes"
options:
description: "Cecil options (optional, `-v` by default)."
default: -v
branding:
icon: 'package'
color: 'white'
icon: package
color: white
runs:
using: 'composite'
using: composite
steps:
- run: |
# Downloading Cecil
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: pre-installed
extensions: mbstring, fileinfo, gd, imagick, intl, gettext, :redis
- name: Validate Cecil version
shell: bash
run: |
version="${{ inputs.version }}"
if [[ -z "$version" ]]; then
echo "No Cecil version provided; using latest release."
elif [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([\-+].*)?$ ]]; then
echo "Invalid Cecil version: '$version' (expected e.g. 8.76.3)" >&2
exit 1
fi
- name: Downloading Cecil
shell: bash
run: |
if [[ -z "${{ inputs.version }}" ]]; then
echo "Downloading Cecil..."
echo "Downloading latest Cecil..."
curl -sSOL https://cecil.app/cecil.phar
else
echo "Downloading Cecil ${{ inputs.version }}..."
curl -sSOL https://cecil.app/download/${{ inputs.version }}/cecil.phar
fi
# Installing theme(s)
if [[ -f "composer.json" && ${{ inputs.install_themes }} = 'yes' ]]; then
- name: Installing theme(s)
shell: bash
run: |
if [[ -f "composer.json" && ( "${{ inputs.install_themes }}" = "yes" || "${{ inputs.install_themes }}" = "true" ) ]]; then
echo "Installing theme(s)..."
composer install --prefer-dist --no-dev --no-progress --no-interaction --quiet
fi
# Running build
if [[ -z "${{ inputs.config }}" ]]; then
php cecil.phar build ${{ inputs.args }}
else
php cecil.phar build ${{ inputs.args }} --config=${{ inputs.config }}
fi
- name: Setup GitHub Pages
id: pages
uses: actions/configure-pages@v6
- name: Building site with Cecil
shell: bash
run: |
php cecil.phar build ${{ inputs.options }} --baseurl="${{ steps.pages.outputs.base_url }}/"
# Summary
if [ $? == 0 ]; then
echo "Site built with Cecil ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
fi
- name: Resolve output directory
id: output
shell: bash
run: |
options='${{ inputs.options }}'
output_dir="_site"
if [[ "$options" =~ (^|[[:space:]])--output=([^[:space:]]+) ]]; then
output_dir="${BASH_REMATCH[2]}"
elif [[ "$options" =~ (^|[[:space:]])--output[[:space:]]+([^[:space:]]+) ]]; then
output_dir="${BASH_REMATCH[2]}"
elif [[ "$options" =~ (^|[[:space:]])-o[[:space:]]+([^[:space:]]+) ]]; then
output_dir="${BASH_REMATCH[2]}"
elif [[ "$options" =~ (^|[[:space:]])-o([^[:space:]]+) ]]; then
output_dir="${BASH_REMATCH[2]}"
fi
echo "output_dir=$output_dir" >> "$GITHUB_OUTPUT"
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: ./${{ steps.output.outputs.output_dir }}