Skip to content
Draft
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
125 changes: 125 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Build assets
on:
pull_request:
branches: [ main ]
jobs:
build_assets:
runs-on: ubuntu-latest
steps:
- name: Checkout theme # 1. Initialize local environment. Checkout code, install tools, etc.
# FIXME - The checkout happens in a detached head state, so the branch
# isn't showing up in the stylesheet correctly. This also may mean an
# orphan commit getting created. Maybe using fetch-depth 0?
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install NPM packages
run: npm install
- name: Compile global # 2a. The actual build - the next three steps are Sass compiling...
uses: gha-utilities/sass-build@v0.2.2
with:
source: css/global.scss
destination: css/build/global.css
- name: Compile forms
uses: gha-utilities/sass-build@v0.2.2
with:
source: css/forms.scss
destination: css/build/forms.css
- name: Compile hours
uses: gha-utilities/sass-build@v0.2.2
with:
source: css/hours.scss
destination: css/build/hours.css
- name: Run Grunt steps # 2b. The rest of the build after Sass happens through Grunt (see
# Gruntfile.js)
run: grunt default
- name: DEBUG inspect build output # At this point, the build is complete. We just need to get the
# output into a state that can be distributed.
# The next few steps confirm that we've built what we expect (the
# stylesheet should have branch information, and there should be built
# css and js files)
run: git status
- name: DEBUG confirm git branch/commit in stylesheet
run: head style.css
- name: DEBUG confirm CSS build output
run: ls -lR ./css/build/
- name: DEBUG confirm JS build output
run: ls -lR ./js/build/

- name: Create swap directory # Ideally this is part of a separate workflow, but I do not want to repeat the build.
# 3. For interim releases, we need to transfer the assets over to
# the dev-release branch. So we copy those assets to a swap
# directory, check out, and then copy them back.
run: mkdir -vp /tmp/swap
- name: Copy file to swap directory
run: cp -R . /tmp/swap
- name: DEBUG Confirm state of swap directory
run: ls -lR /tmp/swap
- name: Checkout dev-release branch
uses: actions/checkout@v2
with:
ref: dev-release
fetch-depth: 0 # TODO - do we need this fetch-depth parameter?
- name: DEBUG Confirm our place in git tree (have we checked out what we expect?)
run: git log --oneline --decorate --graph --all
- name: Copy files from swap directory
run: rsync -rlDz --delete --exclude '.git' /tmp/swap/ .
# I _think_ things are working okay throught this step, but everything
# after this is a bit suspect.
- name: Stage changed files for commit
run: |
git config --local user.email 'action@github.com'
git config --local user.name 'GitHub Action'
git add .
git status
- name: Force-add built content (stylesheets and javascript) - necessary because of .gitignore
run: |
git add -f css/build/*
git add -f js/build/*
- name: DEBUG Confirm scope of changes to dev-release
run: git status
- name: Commit changes # TODO - could we get a better commit message?
run: |
git commit -m 'Updates theme including compiled assets'
- name: Experimental release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Exp release ${{ github.ref }}
body: |
This is an experimental draft release. Where does it appear?
draft: true
prerelease: true
- name: DEBUG Confirm our place in git tree (compare to previous git tree output)
run: git log --oneline --decorate --graph --all
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: dev-release

development_release:
needs: build_assets # This generates the pre-release release of the theme.
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: dev-release
- name: DEBUG confirm our place in git tree
run: git log --oneline --decorate --graph --all
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Dev release ${{ github.ref }}
body: |
This release created automatically. Please edit this text to something meaningful.
draft: false
prerelease: true
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Prepare production release
on:
push:
branches: [ main, engx-117-github-actions ]
jobs:
update_release: # Is it possible to depend on a job from a separate workflow?
needs: build_assets
runs-on: ubuntu-latest
steps:
- name: Checkout theme source
uses: actions/checkout@v2
- name: DEBUG what exists
run: ls -lR .
14 changes: 6 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ module.exports = function(grunt) {
// 1) Javascript preparation (concatenating and uglifying scripts)
grunt.registerTask('javascript', ['concat', 'uglify']);
// 2) Stylesheet preparation (SASS, autoprefixing, and minification)
grunt.registerTask('styles', ['sass', 'autoprefixer', 'cssmin']);
grunt.registerTask('styles', ['autoprefixer', 'cssmin']);
// 3) Appending the most recent git commit to the theme version
grunt.registerTask('release', ['gitinfo', 'replace']);
// The default task performs all three phases.
grunt.registerTask('default', ['javascript', 'styles', 'release']);

// Code analysis is handled via PHP_CodeSniffer
grunt.registerTask('analyze', ['phpcs']);

// Moved to the tasks folder:
// grunt.registerTask('dev', ['connect', 'watch']);

};
// For local development, there is a slightly separate workflow, because
// Sass gets built directly in Grunt (the GH actions workflow handles this
// using a separate taskrunner)
grunt.registerTask('build-local', ['javascript', 'sass', 'styles', 'release']);
};
Empty file added css/build/.gitkeep
Empty file.
Loading