Skip to content
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
60 changes: 60 additions & 0 deletions .github/workflows/migrate-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Migrate Material Images

on:
pull_request:
branches: [main]
paths:
- 'data/materials/**'
push:
branches: [main]
paths:
- 'data/materials/**'

jobs:
migrate-images:
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .

- name: Dry run – show changed material files (PR)
if: github.event_name == 'pull_request'
run: |
python scripts/migrate_images.py \
--dry-run \
--base-ref origin/${{ github.base_ref }}

- name: Migrate images (push to main)
if: github.event_name == 'push'
env:
GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcs-credentials.json
run: |
echo '${{ secrets.GCS_CREDENTIALS_JSON }}' > /tmp/gcs-credentials.json
python scripts/migrate_images.py \
--no-dry-run \
--base-ref HEAD~1

- name: Remove temporary assets and commit (push to main)
if: github.event_name == 'push'
run: |
if [ -d data/tmp ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git rm -rf --ignore-unmatch data/tmp/
git commit -m "chore: remove temporary assets after image migration [skip ci]" || echo "Nothing to commit"
git push
fi
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ __pycache__/
openprinttag/
db-export.json

# Allow local image cache used by migrate-images.py
!data/tmp/
!data/tmp/**

# Python build artifacts
*.egg-info/
*.egg
Expand Down
17 changes: 17 additions & 0 deletions data/materials/generic/pla-army-green.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: PLA Army green
slug: pla-army-green
brand:
slug: generic
class: FFF
type: PLA
abbreviation: ''
tags: []
certifications: []
primary_color:
color_rgba: '#1f6b20ff'
secondary_colors: []
photos:
- url: /tmp/assets/generic/pla-army-green/20260205110532.jpg
type: unspecified
properties: {}
uuid: c6753d1b-4618-505a-aa5a-0676e55e9545
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ dependencies = [
"PyYAML>=6.0",
"jsonschema>=4.0.0",
"referencing>=0.37.0",
"requests>=2.31.0",
"google-cloud-storage>=2.10.0",
]

[tool.setuptools.packages.find]
Expand Down
Loading