Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to get github workflows running #156

Merged
merged 20 commits into from
Dec 3, 2024
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: misspell
uses: reviewdog/action-misspell@v1.10
uses: reviewdog/action-misspell@v1.23
with:
github_token: ${{ secrets.github_token }}
locale: "US"
Expand Down
40 changes: 23 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,44 @@ 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: actions/setup-ruby@v1
uses: ruby/setup-ruby@v1
with:
#TODO: bring this back to 2.7
ruby-version: '2.6'
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Gems
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Install pngout
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
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: Build the static site
run: bundle exec middleman build --bail
- name: Push the static site to prod
- name: Push the static site to stage
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CI_PROD_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_PROD_AWS_SECRET_ACCESS_KEY }}
PROD_S3_BUCKET: ${{ secrets.PROD_S3_BUCKET }}
run: aws s3 sync build $PROD_S3_BUCKET/build/
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')
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install Ruby
uses: actions/setup-ruby@v1
uses: ruby/setup-ruby@v1
with:
#TODO: bring this back to 2.7
ruby-version: '2.6'
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Gems
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: echo $ENV
- name: Attempt to build the static site
run: bundle exec middleman build --bail
Expand Down
32 changes: 23 additions & 9 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,31 @@
# With alternative layout
# page "/path/to/file.html", layout: :otherlayout

# Ignore `photo.html.erb` to prevent it from being processed directly
ignore "photo.html"
ignore "photo.html.erb"

# create a photo landing page for every image
ready do
#TODO: is there a better way to find all images?
images = sitemap.resources.map(&:path)
images = images.select {|s| s =~ /\.(jpg|png)$/i && s !~ /assets\// && s !~ /ogp-image/ }
images = images.map {|i| sitemap.find_resource_by_path(i)}
images.each do |img|
#TODO: add something like this to speed it up?
# next if sitemap.find_resource_by_path(...)
short_path = img.destination_path.sub(/#{File.extname(img.destination_path)}$/, '')
proxy short_path, "/photo.html", layout: 'layout', locals: { photo: img }, ignore: true
# Iterate over all .html.md.erb files to find associated images
sitemap.resources.select { |r| r.path.end_with?(".html") && !r.path.include?("photo.html") }.each do |page|
# Get the directory for the page
page_dir = File.dirname(page.path)

# Find all image files in this directory
Dir.glob("source/#{page_dir}/*.{jpg,png}").each do |image_path|
# Remove "source/" prefix for the relative image path
relative_path = image_path.sub(%r{^source/}, '')

# Get the destination path without the extension
short_path = relative_path.sub(/#{File.extname(relative_path)}$/, '')

# Avoid duplicate proxies
next if sitemap.find_resource_by_path(short_path)

# Create a proxy for the image
proxy short_path, "/photo.html", layout: 'layout', locals: { photo: sitemap.find_resource_by_path(relative_path) }, ignore: true
end
end
end

Expand Down
Loading