Skip to content
Merged

v4 #4

Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ jobs:
uses: ./
with:
version: '8.93.1'
config: 'config.yml'
args: '-vv'
options: '-vv'
install_themes: 'yes'
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 build a [_Cecil_](https://cecil.app) site and upload a GitHub Pages artifact.
Comment thread
ArnaudLigny marked this conversation as resolved.
Outdated

[![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
options: -v --config=config.yml # default: "-v" (verbose)
install_themes: yes # default: "yes"
Comment thread
ArnaudLigny marked this conversation as resolved.
Outdated
```

### 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 to build the site
7. upload artifact
8. deploys `_site` 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
84 changes: 59 additions & 25 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,79 @@
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:
options:
description: "Cecil options (optional, `-v` by default)."
default: -v
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: "Use `no` to do not install theme(s) (optional, `yes` by default)."
Comment thread
ArnaudLigny marked this conversation as resolved.
Outdated
default: yes
Comment thread
ArnaudLigny marked this conversation as resolved.
Outdated
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 [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([\-+].*)?$ ]]; then
Comment thread
ArnaudLigny marked this conversation as resolved.
Outdated
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)
- name: Installing theme(s)
shell: bash
run: |
if [[ -f "composer.json" && ${{ inputs.install_themes }} = 'yes' ]]; 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 }}