The Initialize Action sets up the environment for your workflow, cancels previous runs, and generates a project matrix for subsequent jobs. This action is designed to streamline your CI/CD pipeline by managing previous workflow executions and creating a dynamic project matrix based on changed files.
| Input | Description | Required | Default |
|---|---|---|---|
project-root |
Project root folder | No | . |
script-version |
Version of the script to use | No | 0.5.1 |
| Output | Description |
|---|---|
matrix |
The project matrix for subsequent jobs |
files |
List of changed files |
name: CI Workflow
on:
push:
branches:
- main
- develop
jobs:
initialize:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Initialize Action
uses: robaone/initialize-action@v0.6.0
with:
project-root: 'your/project/root'
# Additional steps to use the outputs can go here
Steps
- Cancel Previous Runs: This step cancels any previous runs if the current branch is not
developormain. - Download Scripts: The action downloads the specified version of the necessary scripts.
- Unzip Scripts: This step extracts the downloaded scripts from the zip file.
- List Modified Files: Uses the
tj-actions/changed-filesaction to gather all modified files and processes them. - Set Dynamic Matrix: This step generates a project matrix based on the modified files and outputs it for use in subsequent jobs.
Here's an example of how you can utilize the outputs of the Initialize Action in your workflow:
name: Continuous Integration & Delivery
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
initialize:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: initialize
id: initialize
uses: robaone/initialize-action@v0.6.0
with:
project-root: .
outputs:
matrix: ${{ steps.initialize.outputs.matrix }}
unit-tests:
needs: [initialize]
strategy:
matrix: ${{ fromJson(needs.initialize.outputs.matrix) }}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
This GitHub Action uses a custom dependency management system based on .depends files. The system is designed to identify which projects are affected by changes to specific files in your repository.
- The action searches for
.dependsfiles in your repository. - Each
.dependsfile should be located in a project directory and contain a list of file paths or patterns that the project depends on. - When files are changed in a pull request or push, the action checks if any of these files match the patterns in the
.dependsfiles. - If a match is found, the corresponding project is identified as affected by the change.
Each line in a .depends file should contain a file path or pattern relative to the repository root. You can use wildcards (*) in these patterns.
Example .depends file:
src/shared/*.js
config/database.yml
*.gemspec
Usage
- Create a
.dependsfile in each project directory that you want to track dependencies for. - List the files or patterns that the project depends on in the
.dependsfile. - When you run this action, it will output the names of projects affected by the changes in your commit or pull request.