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

[CI] Optimise PR previews deployments by sharing resized images #616

Merged
merged 2 commits into from
May 27, 2024
Merged
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
24 changes: 24 additions & 0 deletions .github/workflows/deploy_pr_preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jobs:
env:
APP_ENV: prod
WEBPACK_PUBLIC_PATH: /elao_/pr/${{ github.event.number }}/build
# Will re-use the staging resized images folder in resized image URLs
GLIDE_RESIZED_URL_BASE_PATH: '../../resized'

- name: 'Build static site'
run: bin/console stenope:build --no-interaction -vv --ansi --ignore-content-not-found
Expand All @@ -85,6 +87,28 @@ jobs:
APP_FORCE_NO_INDEX: 1
APP_GITHUB_REF: ${{ github.head_ref }}
ROUTER_DEFAULT_URI: https://elao.github.io/elao_/pr/${{ github.event.number }}
# Will re-use the staging resized images folder in resized image URLs
GLIDE_RESIZED_URL_BASE_PATH: '../../resized'

- name: 'Deduplicate images'
run: |
# Merge the resized images from PR build folder to the cached folder (`public/resized`)
rsync -a build/resized/ public/resized/

# Remove the build resized images folder
rm -rf build/resized/

- name: '🖼️ Push resized images'
uses: JamesIves/github-pages-deploy-action@v4
with:
commit-message: |
[AUTO] Deploy PR #${{ github.event.number }} images

for commit ${{ github.sha }}
branch: gh-pages
folder: public/resized
target-folder: resized
clean: false # Sync we rsynced the images to merge from all source, we'll never delete anything from here.

# https://github.com/marketplace/actions/deploy-to-github-pages
- name: '🚀 Deploy'
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/deploy_staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ jobs:
branch: gh-pages # The branch the action should deploy to.
folder: build # The folder the action should deploy.
clean: true # Automatically remove deleted files from the deploy branch
clean-exclude: 'pr/*' # Don't clean the PR deployments
# Don't clean the PR deployments nor their resized images
clean-exclude: |
pr/*
resized/*
3 changes: 3 additions & 0 deletions config/packages/glide.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
parameters:
glide_public_cache_path_resolved: '%env(string:default:glide_public_cache_path:GLIDE_RESIZED_URL_BASE_PATH)%'

glide:
base_url: /image/resize
source: '%kernel.project_dir%'
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Glide/Bundle/Resources/config/routing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ glide_image_resize:
path: ".+"

glide_image_resized_url:
path: '%glide_public_cache_path%/{path}'
path: '%glide_public_cache_path_resolved%/{path}'
requirements:
path: ".+"
Loading