Step 1. Output webpack stats

@relative-ci/agent uses the JSON output of Webpack stats as a source of data. The following webpack.stats options are needed:

// webpack.config.js
{
  stats: {
    context: './src', // optional, will improve readability of the paths
    assets: true,
    entrypoints: true,
    chunks: true,
    modules: true
  }
}

Select the method to output the webpack stats JSON file:

Step 2. Configure GitHub action

Add relative-ci/agent-action after your build step(the build step will output the webpack stats depending on Step 1. setup).

# .github/workflow/build.yml
name: Build

on: push

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '16.x'

      # Install dependencies
      - run: npm ci

      # Build and output webpack stats to artifacts/webpack-stats.json
      - run: npm run build --if-present

      # Send webpack stats and build information to RelativeCI      - name: Send webpack stats to RelativeCI        uses: relative-ci/agent-action@v1.1.0        with:          webpackStatsFile: ./artifacts/webpack-stats.json          key: ${{ secrets.RELATIVE_CI_KEY }}

pull_request event

When the action is running on the pull_request event, GitHub is reporting the merge commit information:

{
  branch: 'refs/pull/2377/merge',
  commit: 'Merge #abc124 into #abc123'
}

relative-ci/agent-action collects the build information from the event data (event.json) and sends the id & message corresponding to the commit that triggered the pull request.

Workflows triggered by forked repositories (beta)

GitHub actions do not share secrets with workflows triggered by forked repositories. To safely run action steps that require access to secrets, GitHub recommends running the workflow on workflow_run event.

When the workflow is triggered by the workflow_run event, the jobs are running in the context of the base branch, making it safe to access the repository secrets. relative-ci/agent-action collects the build information from the event data (event.json) and the webpack stats from the artifacts uploaded during the build workflow(build.yaml)

Workflow 1: Build and upload webpack stats artifacts

// build.yaml
name: Build

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '16.x'

      # Install dependencies
      - run: npm ci

      # Build and output webpack stats to artifacts/webpack-stats.json      - run: npm run build --if-present      # Upload artifacts/webpack-stats.json to use on relative-ci.yaml      - name: Upload RelativeCI artifacts
        uses: actions/upload-artifact@v2
        with:
          name: relative-ci-artifacts
          path: artifacts

Workflow 2. Send webpack stats and build information to RelativeCI

// relative-ci.yaml
name: RelativeCI

on:
  workflow_run:
    workflows: ["Build"]
    types:
      - completed

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v2
        with:
          node-version: '16.x'

      - name: Send webpack stats to RelativeCI        uses: relative-ci/agent-action@workflow-run-support        with:          # Webpack stats path relative to the artifacts folder          webpackStatsFile: ./webpack-stats.json          # Artifact uploaded during the Build workflow          artifactName: 'relative-ci-artifacts'          # RelativeCI project key          key: ${{ secrets.RELATIVE_CI_KEY }}

Secrets

RELATIVE_CI_KEY

(Required) Navigate to https://app.relative-ci.com and copy the project specific key from Project -> Settings -> Keys.






Need help?Contact us via email, Twitter, or Github!