Fix loop #11
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: Deploy Portal | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'src/**' | |
| - 'public/**' | |
| - 'package.json' | |
| - 'vite.config.ts' | |
| - 'tsconfig.json' | |
| workflow_dispatch: | |
| # Allow only one concurrent deployment | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build portal | |
| run: npm run build | |
| - name: Download frontend builds from GitHub releases | |
| continue-on-error: true | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # Read channels.json to get versions for each channel | |
| for channel in stable beta nightly; do | |
| # Get version from channels.json | |
| VERSION=$(jq -r --arg ch "$channel" '.[$ch] // empty' channels.json) | |
| if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then | |
| echo "No version configured for ${channel}, skipping" | |
| continue | |
| fi | |
| echo "Downloading ${channel} frontend v${VERSION}..." | |
| # Create temp directory | |
| mkdir -p "/tmp/${channel}" | |
| # Download the wheel from GitHub releases | |
| WHEEL_NAME="music_assistant_frontend-${VERSION}-py3-none-any.whl" | |
| if gh release download "${VERSION}" \ | |
| --repo music-assistant/frontend \ | |
| --pattern "${WHEEL_NAME}" \ | |
| --dir "/tmp/${channel}" 2>/dev/null; then | |
| # Extract the wheel | |
| unzip -q "/tmp/${channel}/${WHEEL_NAME}" -d "/tmp/${channel}/extracted" | |
| # Copy to channel subdirectory | |
| mkdir -p "dist/${channel}" | |
| cp -r "/tmp/${channel}/extracted/music_assistant_frontend/"* "dist/${channel}/" | |
| # Create version.json | |
| cat > "dist/${channel}/version.json" << EOF | |
| { | |
| "channel": "${channel}", | |
| "frontend_version": "${VERSION}", | |
| "deployed_at": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" | |
| } | |
| EOF | |
| echo "Restored ${channel} build (v${VERSION})" | |
| else | |
| echo "Failed to download ${channel} frontend v${VERSION}" | |
| fi | |
| done | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: dist/ | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |