jobs:
check-files-changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4.1.7
- name: Получаем перечень изменённых spfx пакетов
id: changed-files-specific
uses: tj-actions/changed-files@v44.5.7
with:
json: 'true'
dir_names: 'true'
files: monorepo/spfx-packages/**
files_ignore: monorepo/spfx-packages/**/*.md
- name: Выводим перечень изменённых spfx пакетов
env:
ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }}
run: |
echo "**************************************"
echo "${ALL_CHANGED_FILES}"
echo "**************************************"
[
"monorepo/spfx-packages/news/src/webparts/news",
"monorepo/spfx-packages/news/config",
"monorepo/spfx-packages/news",
"monorepo/spfx-packages/news/src/webparts/news/loc",
"monorepo/spfx-packages/alert/src/webparts/alert",
"monorepo/spfx-packages/alert/config",
"monorepo/spfx-packages/alert",
"monorepo/spfx-packages/alert/src/webparts/alert/loc"
]
[
"monorepo/spfx-packages/news",
"monorepo/spfx-packages/alert"
]
#!/bin/bash
ALL_CHANGED_FILES='[
"monorepo/spfx-packages/news/src/webparts/news",
"monorepo/spfx-packages/news/config",
"monorepo/spfx-packages/news",
"monorepo/spfx-packages/news/src/webparts/news/loc",
"monorepo/spfx-packages/alert/src/webparts/alert",
"monorepo/spfx-packages/alert/config",
"monorepo/spfx-packages/alert",
"monorepo/spfx-packages/alert/src/webparts/alert/loc"
]'
echo "$ALL_CHANGED_FILES" | sed -rn 's@([^/]+/[^/]+/[^/]+)/.+@\1"@p' | sort -u | sed -r '$!s/.+/&,/'
jobs:
check-files-changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changes: ${{ steps.changed-packages-name.outputs.result }}
steps:
- uses: actions/checkout@v4.1.7
- name: Получаем перечень изменённых файлов spfx пакетов
id: changed-files-specific
uses: tj-actions/changed-files@v44.5.7
with:
json: 'true'
dir_names: 'true'
files: monorepo/spfx-packages/**
files_ignore: monorepo/spfx-packages/**/*.md
- name: Получаем имена изменённых spfx пакетов
id: changed-packages-name
uses: actions/github-script@v7.0.1
env:
ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }}
with:
script: |
const getChangedPackagesOrLibs = require('./.gitea/scripts/js/getChangedPackagesOrLibs.js');
return getChangedPackagesOrLibs('spfx-packages');
// ./.gitea/scripts/js/getChangedPackagesOrLibs.js
/**
* Возвращает массив имён изменённых пакетов или библиотек.
*
* @param {(libs|spfx-packages)} type - Тип: библиотека или spfx-пакет
* @return {Promise<string[]>} - Массив имён изменённых пакетов или библиотек
*/
module.exports = (type) => {
const { ALL_CHANGED_FILES } = process.env;
const changedDirPaths = JSON.parse(JSON.parse(`"${ALL_CHANGED_FILES}"`));
const regex = new RegExp(`(monorepo\/${type}\/)([^\/]+)(.+)?`, 'gm');
const parentDirPaths = [
...(new Set(
changedDirPaths
.map((dirPath) => dirPath.replace(regex, '$2'))
))
];
return parentDirPaths;
}
[
"monorepo/spfx-packages/news/src/webparts/news",
"monorepo/spfx-packages/news/config",
"monorepo/spfx-packages/news",
"monorepo/spfx-packages/news/src/webparts/news/loc",
"monorepo/spfx-packages/alert/src/webparts/alert",
"monorepo/spfx-packages/alert/config",
"monorepo/spfx-packages/alert",
"monorepo/spfx-packages/alert/src/webparts/alert/loc"
]
[
"news",
"alert"
]