Skip to content

Commit 7a58994

Browse files
Build action
1 parent 2a5f28b commit 7a58994

File tree

6 files changed

+35
-53
lines changed

6 files changed

+35
-53
lines changed

.github/workflows/pr-check-files.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@v2
9-
- uses: danieljimeneznz/[email protected].0
9+
- uses: danieljimeneznz/[email protected].1
1010
with:
1111
require-changes-to:
1212
- "dist/index.js"

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
## [4.0.1] - 2021-08-26
11+
### Fixed
12+
- Action built
13+
1014
## [4.0.0] - 2021-08-26
1115
### Added
1216
- GitHub workflow to ensure `dist/index.js` file changes when a PR is created.
@@ -41,7 +45,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4145
- @actions/core 1.2.7 → 1.5.0
4246
- @actions/github 4.0.0 → 5.0.0
4347

44-
[Unreleased]: https://github.com/syeutyu/validate-changed-files/compare/v4.0.0...HEAD
48+
[Unreleased]: https://github.com/syeutyu/validate-changed-files/compare/v4.0.1...HEAD
49+
[4.0.1]: https://github.com/syeutyu/validate-changed-files/compare/v4.0.0...v4.0.1
4550
[4.0.0]: https://github.com/syeutyu/validate-changed-files/compare/v3.0.3...v4.0.0
4651
[3.0.3]: https://github.com/syeutyu/validate-changed-files/compare/v3.0.2...v3.0.3
4752
[3.0.2]: https://github.com/syeutyu/validate-changed-files/compare/v3.0.1...v3.0.2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v2
2727
- run: npm ci
28-
- uses: danieljimeneznz/[email protected].0
28+
- uses: danieljimeneznz/[email protected].1
2929
with:
3030
require-changes-to:
3131
- "package.json"

dist/index.js

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7414,76 +7414,53 @@ async function getCommitBaseHead(context) {
74147414
async function main(
74157415
context,
74167416
client,
7417-
requiredChangePatterns,
7418-
preventModificationPatterns
7417+
requiredFileChanges = [],
7418+
preventFileChanges = []
74197419
) {
7420-
if (requiredChangePatterns && typeof requiredChangePatterns !== "object") {
7421-
core.setFailed(
7422-
"Please fill in the requiredChangePatterns names as an object"
7423-
);
7424-
return;
7425-
}
7426-
7427-
if (
7428-
preventModificationPatterns &&
7429-
typeof preventModificationPatterns !== "object"
7430-
) {
7431-
core.setFailed(
7432-
"Please fill in the preventModificationPatterns names as an object"
7433-
);
7434-
return;
7435-
}
7436-
74377420
const basehead = await getCommitBaseHead(context);
74387421
const commitChanges = await client.rest.repos.compareCommitsWithBasehead({
74397422
...context.repo,
7440-
basehead
7423+
basehead,
74417424
});
7442-
const changedFileNames = commitChanges.data.files.map((f) => f.filename);
7425+
const changedFiles = commitChanges.data.files.map((f) => f.filename);
74437426

7444-
const requiredFileChangesIncluded = !!requiredChangePatterns
7445-
? requiredChangePatterns.every(
7446-
(pattern) => !!changedFileNames.find((file) => minimatch(file, pattern))
7447-
)
7448-
: true;
7427+
const requiredFileChangesIncluded =
7428+
requiredFileChanges.every(
7429+
(pattern) => !!changedFiles.find((file) => minimatch(file, pattern))
7430+
);
74497431

7450-
const preventedFileChangedIncluded = !!preventModificationPatterns
7451-
? preventModificationPatterns.every(
7452-
(pattern) => !!changedFileNames.find((file) => minimatch(file, pattern))
7453-
)
7454-
: false;
7432+
const preventedFileChangedIncluded =
7433+
preventFileChanges.every(
7434+
(pattern) => !!changedFiles.find((file) => minimatch(file, pattern))
7435+
);
74557436

74567437
if (requiredFileChangesIncluded && !preventedFileChangedIncluded) {
74577438
core.setOutput("success", true);
7458-
return;
7439+
return true;
74597440
}
74607441

74617442
core.setFailed(`
74627443
Files changed:\n
7463-
${JSON.stringify(changedFileNames, null, 2)}\n\n
7444+
${JSON.stringify(changedFiles, null, 2)}\n\n
74647445
Please ensure you have changed all files that match the following patterns:\n
7465-
${JSON.stringify(requiredFileChangesIncluded, null, 2)}\n\n
7446+
${JSON.stringify(requiredFileChanges, null, 2)}\n\n
74667447
Please ensure you have not changed any of the files that match the following patterns:\n
7467-
${JSON.stringify(preventedFileChangedIncluded, null, 2)}\n\n
7448+
${JSON.stringify(preventFileChanges, null, 2)}\n\n
74687449
`);
7450+
return false;
74697451
}
74707452

74717453
async function run() {
74727454
const githubToken = core.getInput("token", { required: true });
7473-
const requiredChangePatterns = JSON.parse(
7474-
core.getInput("require-change-file-patterns", { required: false })
7475-
);
7476-
const preventModificationPatterns = JSON.parse(
7477-
core.getInput("prevent-modification-file-patterns", { required: false })
7478-
);
7455+
const requiredFileChanges = core.getMultilineInput("require-changes-to", {
7456+
required: false,
7457+
});
7458+
const preventFileChanges = core.getMultilineInput("prevent-changes-to", {
7459+
required: false,
7460+
});
74797461

74807462
const client = getOctokit(githubToken);
7481-
await main(
7482-
context,
7483-
client,
7484-
requiredChangePatterns,
7485-
preventModificationPatterns
7486-
);
7463+
await main(context, client, requiredFileChanges, preventFileChanges);
74877464
}
74887465

74897466
run();

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ensure-files-changed",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Github action to validate changed files on a pull request",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)