feat: Enable Sentry error tracking by environment (#1642) #308
This file contains hidden or 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: Media Image Check | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "apps/media/content/**" | |
| - "apps/media/public/uploads/posts/**" | |
| - "apps/media/scripts/check-images.mjs" | |
| - "apps/media/scripts/optimize-images.mjs" | |
| - "apps/media/package.json" | |
| - "package.json" | |
| - "pnpm-lock.yaml" | |
| permissions: | |
| contents: read | |
| jobs: | |
| media-image-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.15.1 | |
| run_install: false | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| cache: "pnpm" | |
| - name: Install Safe Chain | |
| run: | | |
| npm install --global @aikidosec/safe-chain | |
| safe-chain setup-ci | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Collect changed media images | |
| id: changed-images | |
| shell: bash | |
| run: | | |
| files_path="$RUNNER_TEMP/changed-media-images.txt" | |
| before_sha="${{ github.event.before }}" | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| git diff -z --name-only --diff-filter=ACMR "origin/${{ github.base_ref }}...${{ github.sha }}" -- \ | |
| 'apps/media/content/**/*.png' \ | |
| 'apps/media/content/**/*.jpg' \ | |
| 'apps/media/content/**/*.jpeg' \ | |
| 'apps/media/content/**/*.webp' \ | |
| 'apps/media/content/**/*.avif' \ | |
| 'apps/media/public/uploads/posts/**/*.png' \ | |
| 'apps/media/public/uploads/posts/**/*.jpg' \ | |
| 'apps/media/public/uploads/posts/**/*.jpeg' \ | |
| 'apps/media/public/uploads/posts/**/*.webp' \ | |
| 'apps/media/public/uploads/posts/**/*.avif' > "$files_path" | |
| elif [ "$before_sha" = "0000000000000000000000000000000000000000" ]; then | |
| git ls-files -z -- \ | |
| 'apps/media/content/**/*.png' \ | |
| 'apps/media/content/**/*.jpg' \ | |
| 'apps/media/content/**/*.jpeg' \ | |
| 'apps/media/content/**/*.webp' \ | |
| 'apps/media/content/**/*.avif' \ | |
| 'apps/media/public/uploads/posts/**/*.png' \ | |
| 'apps/media/public/uploads/posts/**/*.jpg' \ | |
| 'apps/media/public/uploads/posts/**/*.jpeg' \ | |
| 'apps/media/public/uploads/posts/**/*.webp' \ | |
| 'apps/media/public/uploads/posts/**/*.avif' > "$files_path" | |
| elif git cat-file -e "${before_sha}^{commit}" 2>/dev/null; then | |
| git diff -z --name-only --diff-filter=ACMR "$before_sha" "${{ github.sha }}" -- \ | |
| 'apps/media/content/**/*.png' \ | |
| 'apps/media/content/**/*.jpg' \ | |
| 'apps/media/content/**/*.jpeg' \ | |
| 'apps/media/content/**/*.webp' \ | |
| 'apps/media/content/**/*.avif' \ | |
| 'apps/media/public/uploads/posts/**/*.png' \ | |
| 'apps/media/public/uploads/posts/**/*.jpg' \ | |
| 'apps/media/public/uploads/posts/**/*.jpeg' \ | |
| 'apps/media/public/uploads/posts/**/*.webp' \ | |
| 'apps/media/public/uploads/posts/**/*.avif' > "$files_path" | |
| else | |
| echo "Previous commit $before_sha is unavailable in the local clone. Falling back to tracked media images from HEAD." | |
| git diff -z --name-only --diff-filter=ACMR HEAD^ HEAD -- \ | |
| 'apps/media/content/**/*.png' \ | |
| 'apps/media/content/**/*.jpg' \ | |
| 'apps/media/content/**/*.jpeg' \ | |
| 'apps/media/content/**/*.webp' \ | |
| 'apps/media/content/**/*.avif' \ | |
| 'apps/media/public/uploads/posts/**/*.png' \ | |
| 'apps/media/public/uploads/posts/**/*.jpg' \ | |
| 'apps/media/public/uploads/posts/**/*.jpeg' \ | |
| 'apps/media/public/uploads/posts/**/*.webp' \ | |
| 'apps/media/public/uploads/posts/**/*.avif' > "$files_path" \ | |
| || git ls-files -z -- \ | |
| 'apps/media/content/**/*.png' \ | |
| 'apps/media/content/**/*.jpg' \ | |
| 'apps/media/content/**/*.jpeg' \ | |
| 'apps/media/content/**/*.webp' \ | |
| 'apps/media/content/**/*.avif' \ | |
| 'apps/media/public/uploads/posts/**/*.png' \ | |
| 'apps/media/public/uploads/posts/**/*.jpg' \ | |
| 'apps/media/public/uploads/posts/**/*.jpeg' \ | |
| 'apps/media/public/uploads/posts/**/*.webp' \ | |
| 'apps/media/public/uploads/posts/**/*.avif' > "$files_path" | |
| fi | |
| if [ -s "$files_path" ]; then | |
| echo "has_files=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_files=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Check changed media images | |
| if: steps.changed-images.outputs.has_files == 'true' | |
| shell: bash | |
| run: | | |
| xargs -0 pnpm media:check-images -- < "$RUNNER_TEMP/changed-media-images.txt" |