|
| 1 | +name: Build and Deploy |
| 2 | +run-name: ${{ github.actor }} started build action |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - 'v*.*.*' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | + # Allows to run this workflow manually from the Actions tab |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 17 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 18 | +concurrency: |
| 19 | + group: '${{ github.workflow }}-${{ github.ref }}' |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Setup Node.js |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: 20 |
| 34 | + cache: 'npm' |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: npm ci |
| 38 | + |
| 39 | + - name: Build for all browsers |
| 40 | + run: npm run build |
| 41 | + |
| 42 | + - name: Upload Chrome extension artifact |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: chrome-extension |
| 46 | + path: extension/chrome.zip |
| 47 | + |
| 48 | + - name: Upload Firefox extension artifact |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: firefox-extension |
| 52 | + path: extension/firefox.xpi |
| 53 | + |
| 54 | + deploy: |
| 55 | + needs: build |
| 56 | + runs-on: ubuntu-latest |
| 57 | + # Only deploy when a tag is pushed (e.g., v1.0.0) |
| 58 | + if: startsWith(github.ref, 'refs/tags/v') |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Checkout repository |
| 62 | + uses: actions/checkout@v4 |
| 63 | + |
| 64 | + - name: Setup Node.js |
| 65 | + uses: actions/setup-node@v4 |
| 66 | + with: |
| 67 | + node-version: 20 |
| 68 | + cache: 'npm' |
| 69 | + |
| 70 | + - name: Install dependencies |
| 71 | + run: npm ci |
| 72 | + |
| 73 | + - name: Build for all browsers |
| 74 | + run: npm run build |
| 75 | + |
| 76 | + - name: Deploy to extension branch |
| 77 | + uses: peaceiris/actions-gh-pages@v4 |
| 78 | + with: |
| 79 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + publish_dir: ./extension |
| 81 | + publish_branch: extension |
| 82 | + keep_files: false |
0 commit comments