Skip to main content

GitHub Action: monorepo-random-controller

Monorepo random controller used for demo

Introduction

Monorepo pattern for CI/CD use this action as controller to detect list of applications, applications with changes. The GitHub action detects as applications directories from specified path and use random to separate them into changed and unchanged lists.

Usage

  name: Pull Request
on:
pull_request:
branches: [ 'main' ]
types: [opened, synchronize, reopened, closed, labeled, unlabeled]

jobs:
monorepo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Monorepo controller
id: controller
uses: cloudposse/github-action-monorepo-random-[email protected]
with:
dir: ./applications/

outputs:
applications: ${{ steps.controller.outputs.apps }}
changes: ${{ steps.controller.outputs.changes }}
no-changes: ${{ steps.controller.outputs.no-changes }}

ci:
runs-on: ubuntu-latest
needs: [monorepo]
if: ${{ needs.monorepo.outputs.applications != '[]' }}
strategy:
matrix:
application: ${{ fromJson(needs.monorepo.outputs.applications) }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build
id: build
uses: cloudposse/github-action-docker-build-[email protected]
with:
registry: registry.hub.docker.com
organization: ${{ github.event.repository.owner.login }}
repository: ${{ github.event.repository.name }}/${{ matrix.application }}
workdir: ./applications/${{ matrix.application }}

Inputs

NameDescriptionDefaultRequired
dirApplications dirN/Atrue

Outputs

NameDescription
appsApplications list
changesApplications that have changes
no-changesApplications that have no changes