Add build cache for website build job (#158) #12
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
name: Release | |
on: | |
push: | |
tags: | |
- v* | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- id: get-version | |
uses: battila7/get-version-action@v2 | |
- uses: actions/checkout@v2 | |
- name: Install Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
#TODO: bring this back to 2.7 | |
ruby-version: '2.6' | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: Install pngout | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y wget | |
wget https://www.jonof.id.au/files/kenutils/pngout-20200115-linux.tar.gz | |
tar -xvf pngout-20200115-linux.tar.gz | |
sudo mv pngout-20200115-linux/amd64/pngout /usr/local/bin/ | |
rm -rf pngout-20200115-linux* | |
- name: Cache Middleman and image processing files | |
uses: actions/cache@v3 | |
with: | |
path: | | |
.middleman/cache # Middleman cache directory | |
build # Cache the build directory if it's reusable | |
key: middleman-${{ hashFiles('**/*') }} | |
restore-keys: | | |
middleman- | |
- name: Build the static site | |
run: bundle exec middleman build --bail | |
- name: Push the static site to stage | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_SECRET_ACCESS_KEY }} | |
S3_BUCKET: ${{ secrets.STAGE_S3_BUCKET }} | |
run: aws s3 sync build $S3_BUCKET/build/ | |
# - name: Push the static site to prod | |
# env: | |
# AWS_ACCESS_KEY_ID: ${{ secrets.CI_PROD_AWS_ACCESS_KEY_ID }} | |
# AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_PROD_AWS_SECRET_ACCESS_KEY }} | |
# S3_BUCKET: ${{ secrets.PROD_S3_BUCKET }} | |
# run: aws s3 sync build $S3_BUCKET/build/ | |
- name: Post Discord notification | |
if: startsWith(github.ref, 'refs/tags/v') | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
VERSION_TAG: ${{ steps.get-version.outputs.version }} | |
uses: Ilshidur/[email protected] | |
with: | |
args: 'New release created for [{{ EVENT_PAYLOAD.repository.full_name }}]({{ EVENT_PAYLOAD.repository.html_url }}): [{{ VERSION_TAG }}]({{ EVENT_PAYLOAD.compare }})' |