GitHub: Filter out unsupported file types (#26) #94
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: Build Browser Extension | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| workflow_call: | |
| inputs: | |
| browser: | |
| description: Browser platform to build for (e.g., "chrome", '["firefox", "chrome"]') | |
| required: false | |
| default: '["chrome", "firefox"]' | |
| type: string | |
| jobs: | |
| test: | |
| strategy: | |
| matrix: | |
| node-version: [18, 20] | |
| uses: ./.github/workflows/test.yml | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| build: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| browser: ${{ fromJSON(github.event.inputs.browser || '["chrome", "firefox"]') }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node v20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| cache-dependency-path: 'package-lock.json' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build extension for ${{ matrix.browser }} | |
| run: npm run build:${{ matrix.browser }} | |
| - name: Validate build result | |
| if: ${{ matrix.browser == 'firefox' }} | |
| run: | | |
| npm install -g web-ext | |
| # lint the extension before signing | |
| web-ext lint \ | |
| --source-dir="./dist" \ | |
| --output=json \ | |
| --pretty \ | |
| --warnings-as-errors | |
| LINT_EXIT_CODE=$? | |
| if [ $LINT_EXIT_CODE -ne 0 ]; then | |
| echo "::error::Linting failed with exit code $LINT_EXIT_CODE. Build validation for Firefox failed." | |
| exit 1 | |
| fi | |
| - name: Upload extension zip | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.browser }}-extension | |
| path: dist/* | |
| if-no-files-found: error |