diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0fbe3e..76d8d70 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -18,15 +22,21 @@ jobs: cat > pages/index.md <&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 }}