refactor: remove charts.template.html and update charts.html in-place #21
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: CI/CD | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| test: | |
| name: Test & Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm install --legacy-peer-deps | |
| - name: Install Playwright Browsers | |
| run: npx playwright install --with-deps chromium | |
| - name: Build project | |
| run: npm run build | |
| - name: Run tests | |
| run: npm run test | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage/lcov.info | |
| fail_ci_if_error: false | |
| - name: Upload Playwright Report | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| retention-days: 7 | |
| - name: Upload Generated Snapshots | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: generated-snapshots | |
| path: test/integration.spec.js-snapshots/ | |
| retention-days: 7 | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| needs: test | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm install --legacy-peer-deps | |
| - name: Build project | |
| run: npm run build | |
| - name: Update examples | |
| run: npx gulp update | |
| - name: Prepare deployment | |
| run: | | |
| mkdir -p deploy/examples | |
| mkdir -p deploy/node_modules | |
| cp -r dist deploy/ | |
| cp -r examples/* deploy/examples/ | |
| # Copy only required node_modules to keep it small | |
| cp -r node_modules/angular deploy/node_modules/ | |
| cp -r node_modules/chart.js deploy/node_modules/ | |
| cp -r node_modules/angular-bootstrap deploy/node_modules/ | |
| cp -r node_modules/rainbow-code deploy/node_modules/ | |
| cp -r node_modules/font-awesome deploy/node_modules/ | |
| cp -r node_modules/bootstrap deploy/node_modules/ | |
| # Move charts.html to index.html and fix paths | |
| sed -e 's|\.\./node_modules/|node_modules/|g' \ | |
| -e 's|\.\./dist/|dist/|g' \ | |
| -e 's|\.\./angular-chart.js|dist/angular-chart.js|g' \ | |
| -e 's|href="app.css"|href="examples/app.css"|g' \ | |
| -e 's|src="app.js"|src="examples/app.js"|g' \ | |
| -e 's|src="smoothscroll.min.js"|src="examples/smoothscroll.min.js"|g' \ | |
| examples/charts.html > deploy/index.html | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './deploy' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| release: | |
| name: Create GitHub Release | |
| needs: test | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true |