Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb20f4d248 | ||
|
|
b2a0ba40a4 | ||
|
|
c467712045 | ||
|
|
f41e41fa3f | ||
|
|
f490eeaa59 | ||
|
|
37e5be95e2 | ||
|
|
e208eb429a | ||
|
|
c784b6f1c4 | ||
|
|
6dc4095801 | ||
|
|
a522bdb715 |
32
.github/workflows/test.yml
vendored
32
.github/workflows/test.yml
vendored
@@ -5,11 +5,31 @@ on:
|
||||
branches:
|
||||
- "**"
|
||||
pull_request_review:
|
||||
types: [edited, dismissed, submitted]
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
types:
|
||||
- assigned
|
||||
- unassigned
|
||||
- labeled
|
||||
- unlabeled
|
||||
- opened
|
||||
- edited
|
||||
- closed
|
||||
- reopened
|
||||
- synchronize
|
||||
- converted_to_draft
|
||||
- ready_for_review
|
||||
- locked
|
||||
- unlocked
|
||||
- review_requested
|
||||
- review_request_removed
|
||||
- auto_merge_enabled
|
||||
- auto_merge_disabled
|
||||
branches:
|
||||
- main
|
||||
|
||||
|
||||
jobs:
|
||||
shellcheck:
|
||||
name: Run shellcheck
|
||||
@@ -28,6 +48,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
- name: Use Node.js 16.x
|
||||
uses: actions/setup-node@v3.6.0
|
||||
@@ -75,6 +96,7 @@ jobs:
|
||||
|
||||
- name: Push changes
|
||||
if: steps.changed_files.outputs.files_changed == 'true' && github.event_name == 'pull_request'
|
||||
continue-on-error: true
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.PAT_TOKEN }}
|
||||
@@ -101,6 +123,7 @@ jobs:
|
||||
- name: Checkout into dir1
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
path: dir1
|
||||
@@ -133,6 +156,7 @@ jobs:
|
||||
- name: Checkout into dir2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
path: dir2
|
||||
@@ -167,6 +191,7 @@ jobs:
|
||||
- name: Checkout to branch
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download build assets
|
||||
@@ -223,6 +248,7 @@ jobs:
|
||||
- name: Checkout to branch
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download build assets
|
||||
@@ -259,6 +285,7 @@ jobs:
|
||||
- name: Checkout to branch
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download build assets
|
||||
@@ -294,6 +321,7 @@ jobs:
|
||||
- name: Checkout to branch
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: ${{ matrix.fetch-depth }}
|
||||
|
||||
- name: Download build assets
|
||||
@@ -357,6 +385,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: ${{ matrix.fetch-depth }}
|
||||
persist-credentials: false
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
- name: Download build assets
|
||||
uses: actions/download-artifact@v3
|
||||
@@ -538,6 +567,7 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: ${{ matrix.fetch-depth }}
|
||||
- name: Download build assets
|
||||
uses: actions/download-artifact@v3
|
||||
@@ -1228,7 +1258,7 @@ jobs:
|
||||
main-branch-name: ${{ steps.branch-name.outputs.base_ref_branch }}
|
||||
workflow-id: 'test.yml'
|
||||
- name: Run changed-files with a custom base sha
|
||||
if: github.event_name != 'push' && github.event.action != 'closed' && matrix.fetch-depth == 0
|
||||
if: github.event_name != 'push' && github.event.action != 'closed' && matrix.fetch-depth == 0 && steps.last_successful_commit.outputs.base != steps.last_successful_commit.outputs.head
|
||||
id: changed-files-custom-base-sha
|
||||
uses: ./
|
||||
with:
|
||||
|
||||
34
HISTORY.md
34
HISTORY.md
@@ -1,5 +1,39 @@
|
||||
# Changelog
|
||||
|
||||
# [36.0.18](https://github.com/tj-actions/changed-files/compare/v36.0.17...v36.0.18) - (2023-06-06)
|
||||
|
||||
## <!-- 0 -->🚀 Features
|
||||
|
||||
- Add dir_names_exclude_current_dir input and cleaned up logic to retrieve the current sha ([#1229](https://github.com/tj-actions/changed-files/issues/1229)) ([353ea22](https://github.com/tj-actions/changed-files/commit/353ea22e6fc7b15ce3a30064d8cd19eef2a86b71)) - (Tonye Jack)
|
||||
|
||||
## <!-- 26 -->🔄 Update
|
||||
|
||||
- Updated README.md ([#1233](https://github.com/tj-actions/changed-files/issues/1233))
|
||||
|
||||
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([07e0177](https://github.com/tj-actions/changed-files/commit/07e0177b72d3640efced741cae32f9861eee1367)) - (tj-actions[bot])
|
||||
- Updated README.md ([#1232](https://github.com/tj-actions/changed-files/issues/1232))
|
||||
|
||||
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([fee9327](https://github.com/tj-actions/changed-files/commit/fee9327009ff80c0a0d442f2204944771f0552b1)) - (tj-actions[bot])
|
||||
- Update action.yml ([f991633](https://github.com/tj-actions/changed-files/commit/f991633730ca94b13263b3db2bfe3bb4406050e8)) - (Tonye Jack)
|
||||
- Updated README.md ([#1231](https://github.com/tj-actions/changed-files/issues/1231))
|
||||
|
||||
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([1fc4377](https://github.com/tj-actions/changed-files/commit/1fc4377f0376e9e24eb836467b94dc0dbe92087a)) - (tj-actions[bot])
|
||||
- Updated README.md ([#1228](https://github.com/tj-actions/changed-files/issues/1228))
|
||||
|
||||
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([cdf9afc](https://github.com/tj-actions/changed-files/commit/cdf9afcec863cb917421feea4e2d3fef708b2449)) - (tj-actions[bot])
|
||||
- Update README.md ([f58fe58](https://github.com/tj-actions/changed-files/commit/f58fe58af9008ac4c45e7caf949ff95791a9deef)) - (Tonye Jack)
|
||||
- Update action.yml ([9ab4230](https://github.com/tj-actions/changed-files/commit/9ab423063bd7d1ee892ecd5a0ce25f81f604e4f4)) - (Tonye Jack)
|
||||
|
||||
## <!-- 7 -->⚙️ Miscellaneous Tasks
|
||||
|
||||
- **deps:** Update typescript-eslint monorepo to v5.59.9 ([#1227](https://github.com/tj-actions/changed-files/issues/1227)) ([b8dd3a1](https://github.com/tj-actions/changed-files/commit/b8dd3a1a069b5eb261603aa081023c3e9689d6a4)) - (renovate[bot])
|
||||
|
||||
## <!-- 9 -->⬆️ Upgrades
|
||||
|
||||
- Upgraded to v36.0.17 ([#1226](https://github.com/tj-actions/changed-files/issues/1226))
|
||||
|
||||
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([6e4b6b7](https://github.com/tj-actions/changed-files/commit/6e4b6b77a3fd4d60bd02608dba69c7eae38a117f)) - (tj-actions[bot])
|
||||
|
||||
# [36.0.17](https://github.com/tj-actions/changed-files/compare/v36.0.16...v36.0.17) - (2023-06-05)
|
||||
|
||||
## <!-- 7 -->⚙️ Miscellaneous Tasks
|
||||
|
||||
47
dist/index.js
generated
vendored
47
dist/index.js
generated
vendored
@@ -515,7 +515,23 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
||||
}
|
||||
if (previousSha === currentSha) {
|
||||
core.error(`Similar commit hashes detected: previous sha: ${previousSha} is equivalent to the current sha: ${currentSha}.`);
|
||||
core.error(`Please verify that both commits are valid, and increase the fetch_depth to a number higher than ${inputs.fetchDepth}.`);
|
||||
// This occurs if a PR is created from a forked repository and the event is pull_request_target.
|
||||
// - name: Checkout to branch
|
||||
// uses: actions/checkout@v3
|
||||
// Without setting the repository to use the same repository as the pull request will cause the previousSha
|
||||
// to be the same as the currentSha since the currentSha cannot be found in the local history.
|
||||
// The solution is to use:
|
||||
// - name: Checkout to branch
|
||||
// uses: actions/checkout@v3
|
||||
// with:
|
||||
// repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
if (env.GITHUB_EVENT_NAME === 'pull_request_target') {
|
||||
core.warning('If this pull request is from a forked repository, please set the checkout action `repository` input to the same repository as the pull request.');
|
||||
core.warning('This can be done by setting actions/checkout `repository` to ${{ github.event.pull_request.head.repo.full_name }}');
|
||||
}
|
||||
else {
|
||||
core.error(`Please verify that both commits are valid, and increase the fetch_depth to a number higher than ${inputs.fetchDepth}.`);
|
||||
}
|
||||
throw new Error('Similar commit hashes detected.');
|
||||
}
|
||||
return {
|
||||
@@ -573,7 +589,7 @@ exports.getEnv = void 0;
|
||||
const fs_1 = __nccwpck_require__(7147);
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const getEnv = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH;
|
||||
let eventJson = {};
|
||||
if (eventPath) {
|
||||
@@ -587,14 +603,15 @@ const getEnv = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
GITHUB_EVENT_BEFORE: eventJson.before || '',
|
||||
GITHUB_EVENT_BASE_REF: eventJson.base_ref || '',
|
||||
GITHUB_EVENT_RELEASE_TARGET_COMMITISH: ((_e = eventJson.release) === null || _e === void 0 ? void 0 : _e.target_commitish) || '',
|
||||
GITHUB_EVENT_HEAD_REPO_FORK: ((_f = eventJson.head_repo) === null || _f === void 0 ? void 0 : _f.fork) || '',
|
||||
GITHUB_EVENT_PULL_REQUEST_NUMBER: ((_g = eventJson.pull_request) === null || _g === void 0 ? void 0 : _g.number) || '',
|
||||
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ((_j = (_h = eventJson.pull_request) === null || _h === void 0 ? void 0 : _h.base) === null || _j === void 0 ? void 0 : _j.sha) || '',
|
||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ((_l = (_k = eventJson.pull_request) === null || _k === void 0 ? void 0 : _k.head) === null || _l === void 0 ? void 0 : _l.sha) || '',
|
||||
GITHUB_EVENT_HEAD_REPO_FORK: ((_g = (_f = eventJson.head) === null || _f === void 0 ? void 0 : _f.repo) === null || _g === void 0 ? void 0 : _g.fork) || '',
|
||||
GITHUB_EVENT_PULL_REQUEST_NUMBER: ((_h = eventJson.pull_request) === null || _h === void 0 ? void 0 : _h.number) || '',
|
||||
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ((_k = (_j = eventJson.pull_request) === null || _j === void 0 ? void 0 : _j.base) === null || _k === void 0 ? void 0 : _k.sha) || '',
|
||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ((_m = (_l = eventJson.pull_request) === null || _l === void 0 ? void 0 : _l.head) === null || _m === void 0 ? void 0 : _m.sha) || '',
|
||||
GITHUB_EVENT_FORCED: eventJson.forced || '',
|
||||
GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
|
||||
GITHUB_REF: process.env.GITHUB_REF || '',
|
||||
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || ''
|
||||
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || '',
|
||||
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || ''
|
||||
};
|
||||
});
|
||||
exports.getEnv = getEnv;
|
||||
@@ -822,11 +839,11 @@ function run() {
|
||||
}
|
||||
let diffResult;
|
||||
if (!env.GITHUB_EVENT_PULL_REQUEST_BASE_REF) {
|
||||
core.info('Running on a push event...');
|
||||
core.info(`Running on a ${env.GITHUB_EVENT_NAME || 'push'} event...`);
|
||||
diffResult = yield (0, commitSha_1.getSHAForPushEvent)(inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs, isTag);
|
||||
}
|
||||
else {
|
||||
core.info('Running on a pull request event...');
|
||||
core.info(`Running on a ${env.GITHUB_EVENT_NAME || 'pull_request'} event...`);
|
||||
diffResult = yield (0, commitSha_1.getSHAForPullRequestEvent)(inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs);
|
||||
}
|
||||
if (diffResult.initialCommit) {
|
||||
@@ -991,7 +1008,9 @@ function run() {
|
||||
const otherChangedFiles = allOtherChangedFiles
|
||||
.split(inputs.separator)
|
||||
.filter(filePath => !allChangedFiles.split(inputs.separator).includes(filePath));
|
||||
const onlyChanged = otherChangedFiles.length === 0 && allChangedFiles.length > 0;
|
||||
const onlyChanged = otherChangedFiles.length === 0 &&
|
||||
allChangedFiles.length > 0 &&
|
||||
filePatterns.length > 0;
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'only_changed',
|
||||
value: onlyChanged,
|
||||
@@ -1033,7 +1052,9 @@ function run() {
|
||||
const otherModifiedFiles = allOtherModifiedFiles
|
||||
.split(inputs.separator)
|
||||
.filter(filePath => !allModifiedFiles.split(inputs.separator).includes(filePath));
|
||||
const onlyModified = otherModifiedFiles.length === 0 && allModifiedFiles.length > 0;
|
||||
const onlyModified = otherModifiedFiles.length === 0 &&
|
||||
allModifiedFiles.length > 0 &&
|
||||
filePatterns.length > 0;
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'only_modified',
|
||||
value: onlyModified,
|
||||
@@ -1075,7 +1096,9 @@ function run() {
|
||||
const otherDeletedFiles = allOtherDeletedFiles
|
||||
.split(inputs.separator)
|
||||
.filter(filePath => !deletedFiles.split(inputs.separator).includes(filePath));
|
||||
const onlyDeleted = otherDeletedFiles.length === 0 && deletedFiles.length > 0;
|
||||
const onlyDeleted = otherDeletedFiles.length === 0 &&
|
||||
deletedFiles.length > 0 &&
|
||||
filePatterns.length > 0;
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'only_deleted',
|
||||
value: onlyDeleted,
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -469,9 +469,28 @@ export const getSHAForPullRequestEvent = async (
|
||||
core.error(
|
||||
`Similar commit hashes detected: previous sha: ${previousSha} is equivalent to the current sha: ${currentSha}.`
|
||||
)
|
||||
core.error(
|
||||
`Please verify that both commits are valid, and increase the fetch_depth to a number higher than ${inputs.fetchDepth}.`
|
||||
)
|
||||
// This occurs if a PR is created from a forked repository and the event is pull_request_target.
|
||||
// - name: Checkout to branch
|
||||
// uses: actions/checkout@v3
|
||||
// Without setting the repository to use the same repository as the pull request will cause the previousSha
|
||||
// to be the same as the currentSha since the currentSha cannot be found in the local history.
|
||||
// The solution is to use:
|
||||
// - name: Checkout to branch
|
||||
// uses: actions/checkout@v3
|
||||
// with:
|
||||
// repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
if (env.GITHUB_EVENT_NAME === 'pull_request_target') {
|
||||
core.warning(
|
||||
'If this pull request is from a forked repository, please set the checkout action `repository` input to the same repository as the pull request.'
|
||||
)
|
||||
core.warning(
|
||||
'This can be done by setting actions/checkout `repository` to ${{ github.event.pull_request.head.repo.full_name }}'
|
||||
)
|
||||
} else {
|
||||
core.error(
|
||||
`Please verify that both commits are valid, and increase the fetch_depth to a number higher than ${inputs.fetchDepth}.`
|
||||
)
|
||||
}
|
||||
throw new Error('Similar commit hashes detected.')
|
||||
}
|
||||
|
||||
|
||||
12
src/env.ts
12
src/env.ts
@@ -15,6 +15,7 @@ export type Env = {
|
||||
GITHUB_EVENT_PULL_REQUEST_NUMBER: string
|
||||
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: string
|
||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: string
|
||||
GITHUB_EVENT_NAME: string
|
||||
}
|
||||
|
||||
type GithubEvent = {
|
||||
@@ -35,8 +36,10 @@ type GithubEvent = {
|
||||
}
|
||||
before?: string
|
||||
base_ref?: string
|
||||
head_repo?: {
|
||||
fork: string
|
||||
head?: {
|
||||
repo?: {
|
||||
fork: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +60,14 @@ export const getEnv = async (): Promise<Env> => {
|
||||
GITHUB_EVENT_BASE_REF: eventJson.base_ref || '',
|
||||
GITHUB_EVENT_RELEASE_TARGET_COMMITISH:
|
||||
eventJson.release?.target_commitish || '',
|
||||
GITHUB_EVENT_HEAD_REPO_FORK: eventJson.head_repo?.fork || '',
|
||||
GITHUB_EVENT_HEAD_REPO_FORK: eventJson.head?.repo?.fork || '',
|
||||
GITHUB_EVENT_PULL_REQUEST_NUMBER: eventJson.pull_request?.number || '',
|
||||
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: eventJson.pull_request?.base?.sha || '',
|
||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: eventJson.pull_request?.head?.sha || '',
|
||||
GITHUB_EVENT_FORCED: eventJson.forced || '',
|
||||
GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
|
||||
GITHUB_REF: process.env.GITHUB_REF || '',
|
||||
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || ''
|
||||
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || '',
|
||||
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || ''
|
||||
}
|
||||
}
|
||||
|
||||
19
src/main.ts
19
src/main.ts
@@ -67,7 +67,7 @@ export async function run(): Promise<void> {
|
||||
let diffResult: DiffResult
|
||||
|
||||
if (!env.GITHUB_EVENT_PULL_REQUEST_BASE_REF) {
|
||||
core.info('Running on a push event...')
|
||||
core.info(`Running on a ${env.GITHUB_EVENT_NAME || 'push'} event...`)
|
||||
diffResult = await getSHAForPushEvent(
|
||||
inputs,
|
||||
env,
|
||||
@@ -78,7 +78,9 @@ export async function run(): Promise<void> {
|
||||
isTag
|
||||
)
|
||||
} else {
|
||||
core.info('Running on a pull request event...')
|
||||
core.info(
|
||||
`Running on a ${env.GITHUB_EVENT_NAME || 'pull_request'} event...`
|
||||
)
|
||||
diffResult = await getSHAForPullRequestEvent(
|
||||
inputs,
|
||||
env,
|
||||
@@ -271,7 +273,9 @@ export async function run(): Promise<void> {
|
||||
)
|
||||
|
||||
const onlyChanged =
|
||||
otherChangedFiles.length === 0 && allChangedFiles.length > 0
|
||||
otherChangedFiles.length === 0 &&
|
||||
allChangedFiles.length > 0 &&
|
||||
filePatterns.length > 0
|
||||
|
||||
await setOutput({
|
||||
key: 'only_changed',
|
||||
@@ -323,7 +327,9 @@ export async function run(): Promise<void> {
|
||||
)
|
||||
|
||||
const onlyModified =
|
||||
otherModifiedFiles.length === 0 && allModifiedFiles.length > 0
|
||||
otherModifiedFiles.length === 0 &&
|
||||
allModifiedFiles.length > 0 &&
|
||||
filePatterns.length > 0
|
||||
|
||||
await setOutput({
|
||||
key: 'only_modified',
|
||||
@@ -374,7 +380,10 @@ export async function run(): Promise<void> {
|
||||
filePath => !deletedFiles.split(inputs.separator).includes(filePath)
|
||||
)
|
||||
|
||||
const onlyDeleted = otherDeletedFiles.length === 0 && deletedFiles.length > 0
|
||||
const onlyDeleted =
|
||||
otherDeletedFiles.length === 0 &&
|
||||
deletedFiles.length > 0 &&
|
||||
filePatterns.length > 0
|
||||
|
||||
await setOutput({
|
||||
key: 'only_deleted',
|
||||
|
||||
Reference in New Issue
Block a user