Skip to content
Snippets Groups Projects
  • Tom Herbers's avatar
    1523a2f4
    github: build-gluon: cancel obsolete in progress workflows for PRs (#3115) · 1523a2f4
    Tom Herbers authored
    Goal is to cancel Worfklows for Pull Request if they become obsolte
    due to new changes.
    Without this workflows will continue running, wasting resources and
    delaying the run of relevant workflows.
    This situation will typically occour if a author of a PR notices an
    error/typo/missing bit and pushes new changes to the branch.
    
    This won't affect concurrent workflows for otherwise triggered
    workflows (push, workflow_dispatch, tag, ...).
    github: build-gluon: cancel obsolete in progress workflows for PRs (#3115)
    Tom Herbers authored
    Goal is to cancel Worfklows for Pull Request if they become obsolte
    due to new changes.
    Without this workflows will continue running, wasting resources and
    delaying the run of relevant workflows.
    This situation will typically occour if a author of a PR notices an
    error/typo/missing bit and pushes new changes to the branch.
    
    This won't affect concurrent workflows for otherwise triggered
    workflows (push, workflow_dispatch, tag, ...).
build-gluon.yml 1.91 KiB
name: Build Gluon
on:
  push:
    branches:
      - master
      - next
      - 'v20[2-9][0-9].[0-9].x'
  pull_request:
    types: [opened, synchronize, reopened]
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref || github.run_id }}-${{ github.event.pull_request.number || github.run_id }}
  cancel-in-progress: true

jobs:
  changed:
    permissions:
      contents: read  # for dorny/paths-filter to fetch a list of changed files
      pull-requests: read  # for dorny/paths-filter to read pull requests
    runs-on: ubuntu-22.04
    outputs:
      targets: ${{ steps.filter.outputs.changes }}
    steps:
      - uses: actions/checkout@v4

      # Filter targets based on changed files
      - uses: dorny/paths-filter@v2
        id: filter
        with:
          filters: .github/filters.yml

  build_firmware:
    needs: changed
    if: ${{ needs.changed.outputs.targets != '[]' && needs.changed.outputs.targets != '' }}
    strategy:
      fail-fast: false
      matrix:
        # Read back changed targets to create build matrix
        target: ${{ fromJSON(needs.changed.outputs.targets) }}
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4

      - name: Show system information
        run: contrib/actions/show-system-info.sh

      - name: Build Docker container
        run: docker build -t gluon-ci-container contrib/docker

      - name: Build Gluon
        run: docker run --rm -v $PWD:/gluon-ci -w /gluon-ci --user "$(id -u):$(id -g)" gluon-ci-container contrib/actions/run-build.sh ${{ matrix.target }}

      - name: Archive build logs
        if: ${{ !cancelled() }}
        uses: actions/upload-artifact@v3
        with:
          name: ${{ matrix.target }}_logs
          path: openwrt/logs

      - name: Archive build output
        uses: actions/upload-artifact@v3
        with:
          name: ${{ matrix.target }}_output
          path: output