New post: latest developments #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with using HydePHP with GitHub Actions | |
name: Build & Deploy | |
# Controls when the workflow will run | |
on: | |
# We only want to run this workflow when changes are pushed to the master/main branch | |
push: | |
branches: [ "master" ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# First we need to build the site | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so the job can access it | |
- uses: actions/checkout@v3 | |
# (optional) Validate the Composer files to catch any errors early on | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict | |
# (optional) Cache the Composer packages to speed up future builds | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
# Install the Composer packages | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress | |
# Now we can build the site! We do this using the HydeCLI | |
- name: Build the site | |
run: php hyde build --no-interaction | |
# Our site is now compiled into the _site directory, so we'll upload it to an artifact to use in the next job | |
- name: Upload site artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: site | |
path: _site | |
# Now we can deploy the site to GitHub Pages! | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build # Run the build job first, otherwise we won't have anything to deploy | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: 'gh-pages' # Checkout the gh-pages branch | |
# (optional) Remove any old files from the gh-pages branch | |
- name: Empty site directory | |
run: rm -rf * | |
# Download the compiled site into the current directory | |
- name: Download site artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: site | |
path: '.' | |
# Create a .nojekyll file to prevent GitHub from attempting to compile a Jekyll site | |
- name: Create .nojekyll file | |
run: touch .nojekyll | |
# Commit the changes to the gh-pages branch | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: '.' | |
message: 'Upload compiled site ${{ github.sha }}' |