Add watchdogGradient Theme #27
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: PR Preview | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| preview: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Checkout PR Branch | |
| uses: actions/checkout@v4 | |
| - name: Checkout main branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| path: main-branch | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: true | |
| - name: Find new theme | |
| id: get-theme | |
| run: | | |
| # Extract themes from both branches | |
| PR_THEMES=$(pnpm tsx -e "import { preset } from './src/theme'; console.log(Object.keys(preset).join(','))") | |
| MAIN_THEMES=$(pnpm tsx -e "import { preset } from './main-branch/src/theme'; console.log(Object.keys(preset).join(','))") | |
| # Convert to arrays | |
| IFS=',' read -ra PR_ARRAY <<< "$PR_THEMES" | |
| IFS=',' read -ra MAIN_ARRAY <<< "$MAIN_THEMES" | |
| # Find new themes | |
| NEW_THEMES=() | |
| for theme in "${PR_ARRAY[@]}"; do | |
| if [[ ! " ${MAIN_ARRAY[@]} " =~ " ${theme} " ]]; then | |
| NEW_THEMES+=("$theme") | |
| fi | |
| done | |
| if [ ${#NEW_THEMES[@]} -eq 0 ]; then | |
| THEME="light" | |
| echo "No new theme found, using default: $THEME" | |
| else | |
| THEME="${NEW_THEMES[0]}" | |
| echo "New theme found: $THEME" | |
| fi | |
| echo "theme=$THEME" >> $GITHUB_OUTPUT | |
| # Store all new themes for the comment | |
| if [ ${#NEW_THEMES[@]} -gt 0 ]; then | |
| echo "new_themes=${NEW_THEMES[*]}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate preview grid | |
| run: | | |
| pnpm generate --grid --theme ${{ steps.get-theme.outputs.theme }} -o preview.png || { | |
| echo "::error::Failed to generate preview cards" | |
| exit 1 | |
| } | |
| - name: Upload preview artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: preview-image | |
| path: preview.png | |
| retention-days: 1 | |
| - name: Save PR info | |
| run: | | |
| echo "${{ github.event.pull_request.number }}" > pr_number.txt | |
| echo "${{ github.event.pull_request.head.sha }}" > commit_sha.txt | |
| echo "${{ steps.get-theme.outputs.new_themes }}" > new_themes.txt | |
| echo "${{ steps.get-theme.outputs.theme }}" > theme.txt | |
| - name: Upload PR info artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pr-info | |
| path: | | |
| pr_number.txt | |
| commit_sha.txt | |
| new_themes.txt | |
| theme.txt | |
| retention-days: 1 |