Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): restore accidentally deleted shared workflow #290

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 76 additions & 21 deletions .github/workflows/pipeline-npm-package.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,86 @@
name: Juno NPM Package Pipeline
# Run it locally with act (https://github.com/nektos/act)
# 1. Install act:
# `brew install act`
# 2. Create a .secret file with the following content:
# `GITHUB_TOKEN=your_github_token`
# PULL REQUEST
# 1. Create a act_pull_request.json file in case of a pull request with the following content:
# `{"inputs": {"paths": "packages/juno-ui-components apps/exampleapp", "node": "20.x", "runs-on": "ubuntu-latest"}}`
# 2. Run the following command:
# `act workflow_call -e act_workflow_call_ci.json -W .github/workflows/check-changes-npm-package.yaml`

on:
pull_request:
types: [opened, synchronize] # Triggers when a PR is opened or updated
name: Detect Changes on the given Paths

env:
HUSKY: 0
ArtieReus marked this conversation as resolved.
Show resolved Hide resolved
on:
workflow_call:
inputs:
paths:
description: "Space separated list of paths indicating where to collect packages to be check for changes. Example: 'packages' will check all packages in the packages folder."
required: false
type: string
folders:
description: "Space-separated list of folders to be checked for changes. Example: 'packages/communicator packages/juno-ui-components' checks for changes in the communicator and juno-ui-components packages. You can use wildcards to check all packages within a specific folder. Example: '*/ui' checks all packages with a ui folder at the second level."
required: false
type: string
runs-on:
description: "The runner to use for the job"
required: false
default: "default"
type: string
outputs:
changes:
description: "List of found changes in the paths"
value: ${{ jobs.detect-changes.outputs.changes }}

jobs:
input-processing:
runs-on: ubuntu-latest
detect-changes:
runs-on: ${{ inputs.runs-on}}
outputs:
changes: ${{ steps.package-filters.outputs.changes}}
steps:
- name: Print Inputs
run: |
echo "====${{ github.workflow }} Inputs===="
echo "Inputs: ${{ github.event }}"
echo "Inputs: ${{ toJson(inputs) }}"
echo "===="

check-licenses:
needs: [input-processing]
runs-on: ubuntu-latest
steps:
- name: Check Licenses
run: echo "License check logic goes here"
- name: Checkout
uses: actions/checkout@v4

test-unit-and-build:
needs: [input-processing, check-licenses]
runs-on: ubuntu-latest
steps:
- name: Run Tests and Build
run: echo "Test and build logic goes here"
- name: Generate filters
id: generate-filters
run: |
items=()
echo "" > package_filters.yaml

if [ -n "${{ inputs.paths }}" ]; then
# Create a filter for each folder/package in the paths
for path in ${{ inputs.paths }}; do
for folder in $path/*; do
echo "$folder: $folder/**" >> package_filters.yaml
done
done
fi

if [ -n "${{ inputs.folders }}" ]; then
# Create a filter for each folder
for folder in ${{ inputs.folders }}; do
echo "$folder: $folder/**" >> package_filters.yaml
done
fi

- name: Set specific filters for the packages wihtin the paths
uses: dorny/paths-filter@v3
id: package-filters
with:
list-files: json
filters: package_filters.yaml

- name: Show outputs
run: |
echo "===${{ github.workflow }} Outputs==="
echo "====Package filters===="
cat package_filters.yaml
echo "========"
echo changed packages: ${{ steps.package-filters.outputs.changes}}
echo "===================="
Loading