Github Action: run one step before matrix combinations

Viewed 1260

I'm creating a Github Action Workflow.
There is a phing build file that creates multiple zips depending on product variations. This is done with a matrix.

Before the product is build there is a JS File that needs to be build. That's done with a rollup build file.

Everything works fine, but the JS build only needs to be done once and not with every matrix combination.

I don't know how that should be done. Maybe with a single separate workflow running at start, but how would the finished JS file be pushed into the next workflow? Or maybe one workflow is fine?

name: Build

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      VERSION: 1.0.1
    strategy:
      matrix:
        edition: ["product1", "product2", "product3"]
        limits: [100, 200, 300]
        exclude:
          - edition: product1
            limits: 100
          - edition: product2
            limits: 100
          - edition: product1
            limits: 200
          - edition: product2
            limits: 200
    steps:
      - uses: actions/checkout@v2

      - name: Build JS
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: Cache Node.js modules
        uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.OS }}-node-
            ${{ runner.OS }}-
      - run: npm ci
      - run: npm run build # builds main.js

      - name: Phing Build
        uses: phingofficial/phing-github-action@main
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          buildfile: build/phing/build.xml
          targets: main
          user-properties: editions=${{ matrix.edition }} limits=${{ matrix.limits }}
          version: 3.0.0-alpha4

      - name: Archive code
        uses: actions/upload-artifact@v2
        with:
          name: file-${{ matrix.edition }}${{ matrix.limits }}-v${{ env.VERSION }}
          path: build/${{ matrix.edition }}/zip/
          retention-days: 1
0 Answers
Related