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

add logs #3

Merged
merged 15 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
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
Next Next commit
add logs
  • Loading branch information
mgrybyk committed Aug 24, 2023
commit f1a443fa43e3c6c1c9dab835c2c34db7a9121299
30 changes: 4 additions & 26 deletions .github/workflows/report_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,10 @@ jobs:
# you must check out the repository
- uses: actions/checkout@v3

- run: npm ci --no-fund --no-audit --no-progress
- run: npm run checks
- run: npm run build
- name: Make sure dist was commited before push
run: |
git status -s -uno
[ $(git status -s -uno | wc -l | bc ) != "0" ] && exit 1 || echo OK

- name: Checkout test-action
uses: actions/checkout@v3
with:
ref: test-action # branch name
path: test-action-dir # checkout path

- run: cd test-action-dir && echo '1' >> f && git status -s && git diff --staged --name-only
- name: Local git-commit-pull-push-action 1
uses: ./
with:
repository: test-action-dir
branch: test-action
commit_message: message ${{ github.run_id }}
pull_args: --dry-run

- run: cd test-action-dir && echo '2' >> f && git status -s && git diff --staged --name-only
- run: cd dist && echo '1' >> f.png && git status -s && git diff --staged --name-only
- name: Local git-commit-pull-push-action 2
uses: ./
with:
repository: test-action-dir
branch: test-action
branch: ${{ github.head_ref }}
commit_message: Update screenshots
add_args: 'tests/**/*.png'
14 changes: 8 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2720,6 +2720,7 @@ try {
branch,
commitMessage,
pullArgs,
addArgs,
});
if (!(await (0,_src_isFileExists_js__WEBPACK_IMPORTED_MODULE_1__/* .isFileExist */ .e)(repository))) {
throw new Error("repository directory doesn't exist: " + repository);
Expand All @@ -2729,22 +2730,23 @@ try {
}
await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['config', '--global', 'user.name', '"github-actions[bot]"'], repository);
await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['config', '--global', 'user.email', '"41898282+github-actions[bot]@users.noreply.github.com"'], repository);
await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['add', ...addArgs.split(' ')], repository);
console.log('add', await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['add', ...addArgs.split(' ')], repository));
const diff = await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['diff', '--staged', '--name-only'], repository);
console.log('diff', diff);
if (diff.trim() === '') {
console.log('Working tree is empty. Nothing to commit.');
}
else {
await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', [
console.log('commit', await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', [
'commit',
'-m',
commitMessage,
'--author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"',
'--no-verify',
], repository);
await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['pull', 'origin', branch, ...pullArgs.split(' ')], repository);
await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['checkout', branch], repository);
await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['push', '--no-verify', 'origin', branch], repository);
], repository));
console.log('pull', await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['pull', 'origin', branch, ...pullArgs.split(' ')], repository));
console.log('checkout', await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['checkout', branch], repository));
console.log('push', await (0,_src_spawnProcess_js__WEBPACK_IMPORTED_MODULE_2__/* .spawnProcess */ .y)('git', ['push', '--no-verify', 'origin', branch], repository));
}
}
catch (error) {
Expand Down
33 changes: 19 additions & 14 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ try {
branch,
commitMessage,
pullArgs,
addArgs,
})

if (!(await isFileExist(repository))) {
Expand All @@ -29,25 +30,29 @@ try {
await spawnProcess('git', ['config', '--global', 'user.name', '"github-actions[bot]"'], repository)
await spawnProcess('git', ['config', '--global', 'user.email', '"41898282+github-actions[bot]@users.noreply.github.com"'], repository)

await spawnProcess('git', ['add', ...addArgs.split(' ')], repository)
console.log('add', await spawnProcess('git', ['add', ...addArgs.split(' ')], repository))
const diff = await spawnProcess('git', ['diff', '--staged', '--name-only'], repository)
console.log('diff', diff)
if (diff.trim() === '') {
console.log('Working tree is empty. Nothing to commit.')
} else {
await spawnProcess(
'git',
[
'commit',
'-m',
commitMessage,
'--author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"',
'--no-verify',
],
repository
console.log(
'commit',
await spawnProcess(
'git',
[
'commit',
'-m',
commitMessage,
'--author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"',
'--no-verify',
],
repository
)
)
await spawnProcess('git', ['pull', 'origin', branch, ...pullArgs.split(' ')], repository)
await spawnProcess('git', ['checkout', branch], repository)
await spawnProcess('git', ['push', '--no-verify', 'origin', branch], repository)
console.log('pull', await spawnProcess('git', ['pull', 'origin', branch, ...pullArgs.split(' ')], repository))
console.log('checkout', await spawnProcess('git', ['checkout', branch], repository))
console.log('push', await spawnProcess('git', ['push', '--no-verify', 'origin', branch], repository))
}
} catch (error) {
core.setFailed(error.message)
Expand Down