Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,11 @@
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

---
## [Unreleased](https://github.com/ryancyq/github-signed-commit/tree/HEAD)
## [1.3.0](https://github.com/ryancyq/github-signed-commit/compare/v1.2.0..v1.3.0) - 2024-10-30

### Features

- Add support for remote GitHub repository + working directory ([#2](https://github.com/ryancyq/github-signed-commit/issues/2)) - ([2c19408](https://github.com/ryancyq/github-signed-commit/commit/2c19408618f096a6064093809288c28e3f4daaa1)) - Xavier Krantz

### Documentation

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,8 +63,9 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `files` | **YES** | Multi-line string of file paths to be committed, relative to the current workspace.|
| `workspace` | **NO** | Directory containing files to be committed. **DEFAULT:** GitHub workspace directory (root of the repository). |
| `commit-message` | **YES** | Commit message for the file changes. |
| `repository` | **NO** | Repository name including owner (e.g. owner/repo). **DEFAULT:** Workflow triggered repository |
| `branch-name` | **NO** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch |
| `owner` | **NO** | GitHub repository owner (user or organization), defaults to the repo invoking the action. |
| `repo` | **NO** | GitHub repository name, defaults to the repo invoking the action. |
| `branch-name` | **NO*** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch. **REQUIRED:** If triggered through `on tags`.|
| `branch-push-force` | **NO** | `--force` flag when running `git push <branch-name>`. |
| `tag` | **NO** | Push tag for the new/current commit. |
| `tag-only-if-file-changes` | **NO** | Push tag for new commit only when file changes present. **DEFAULT:** true |
Expand All@@ -75,9 +76,18 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `commit-sha` | Full SHA of the signed commit. |
| `tag` | Tag of the signed commit. |

## Release

This project follows [Conventional Commits](https://www.conventionalcommits.org/) and uses a manual release workflow.

1. Ensure `dist/` is up-to-date by running `npm run bundle`
2. Trigger the **Release** workflow via `workflow_dispatch` with the desired [semver](https://semver.org/) version
- The workflow bumps `package.json`, creates a signed commit, and tags `v{version}`
3. The **Changelog** workflow automatically regenerates `CHANGELOG.md` from conventional commits using [git-cliff](https://git-cliff.org/)

[ci_badge]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml/badge.svg
[ci_workflows]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml
[coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2
[coverage]: https://codecov.io/gh/ryancyq/github-signed-commit
[maintainability_badge]: https://api.codeclimate.com/v1/badges/0de9dbec270ca85719c6/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
17 changes: 17 additions & 0 deletions __tests__/blob.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,23 @@ describe('Blob', () => {
})
})

it('binary file successfully', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0xff, 0xfe, 0x00, 0x80,
0xc0, 0xc1, 0xf5, 0xf6,
])
const binaryPath = join(__dirname, 'fixtures', 'blob.bin')
fs.writeFileSync(binaryPath, binaryContent)

try {
const blob = getBlob('fixtures/blob.bin')
const fileAddition = await blob.load()
expect(fileAddition.contents).toEqual(binaryContent.toString('base64'))
} finally {
fs.unlinkSync(binaryPath)
}
})

it('stream with error', async () => {
const blob = getBlob('fixtures/error.txt')
const mockStream = new PassThrough()
Expand Down
4 changes: 2 additions & 2 deletions __tests__/git.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -182,7 +182,7 @@ describe('Git CLI', () => {

describe('git add', () => {
beforeEach(() => {
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('/test-workspace')
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('test-workspace/')
})

it('should ensure file paths are within curent working directory', async () => {
Expand All@@ -191,7 +191,7 @@ describe('Git CLI', () => {
await addFileChanges(['*.ts', '~/.bashrc'])
expect(execMock).toHaveBeenCalledWith(
'git',
['add', '--', '/test-workspace/*.ts', '/test-workspace/~/.bashrc'],
['add', '--', 'test-workspace/*.ts', 'test-workspace/~/.bashrc'],
expect.objectContaining({
listeners: { stdline: expect.anything(), errline: expect.anything() },
})
Expand Down
36 changes: 0 additions & 36 deletions __tests__/main.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,42 +205,6 @@ describe('action', () => {
})
})

describe('input repository is given', () => {
describe('valid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user/the-repo'
return ''
})
})

it('succeed', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Neither files nor tag input has been configured'
)
})
})

describe('invalid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user-the-repo'
return ''
})
})

it('fails', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Input <repository> "the-user-the-repo" is invalid'
)
})
})
})

describe('input branch is given', () => {
beforeEach(() => {
jest.spyOn(core, 'getMultilineInput').mockReturnValue(['/test.txt'])
Expand Down
14 changes: 14 additions & 0 deletions __tests__/stream/base64-encoder.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,4 +15,18 @@ describe('Base64 Encoder', () => {
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(Buffer.from(content).toString('base64'))
})

it('binary buffer stream', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0xff, 0xfe, 0x00, 0x80, 0xc0, 0xc1,
])
const stream = Readable.from(binaryContent).pipe(new Base64Encoder())

const chunks: Buffer[] = []
for await (const chunk of stream) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
}
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(binaryContent.toString('base64'))
})
})
14 changes: 11 additions & 3 deletions action.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,15 +15,23 @@ inputs:
Directory containing files to be committed. Default: GitHub workspace directory (root of repository).
required: false
default: ''
workdir:
description: |
Directory where the action should run. Default: GitHub workspace directory (root of repository from where the GH Workflow is triggered).
required: false
default: ''
commit-message:
description: |
Commit message for the file changes.
required: false
repository:
owner:
description: |
Repository name including owner (e.g. owner/repo). Default: Workflow triggered repository.
GitHub repository owner (user or organization), defaults to the repo invoking the action.
required: false
repo:
description: |
GitHub repository name, defaults to the repo invoking the action.
required: false
default: ''
branch-name:
description: |
Branch to commit to. Default: Workflow triggered branch.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
feat: Add support for remote GitHub repository + working directory (#2) by xakraz · Pull Request #211 · ryancyq/github-signed-commit · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,11 @@
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

---
## [Unreleased](https://github.com/ryancyq/github-signed-commit/tree/HEAD)
## [1.3.0](https://github.com/ryancyq/github-signed-commit/compare/v1.2.0..v1.3.0) - 2024-10-30

### Features

- Add support for remote GitHub repository + working directory ([#2](https://github.com/ryancyq/github-signed-commit/issues/2)) - ([2c19408](https://github.com/ryancyq/github-signed-commit/commit/2c19408618f096a6064093809288c28e3f4daaa1)) - Xavier Krantz

### Documentation

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,8 +63,9 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `files` | **YES** | Multi-line string of file paths to be committed, relative to the current workspace.|
| `workspace` | **NO** | Directory containing files to be committed. **DEFAULT:** GitHub workspace directory (root of the repository). |
| `commit-message` | **YES** | Commit message for the file changes. |
| `repository` | **NO** | Repository name including owner (e.g. owner/repo). **DEFAULT:** Workflow triggered repository |
| `branch-name` | **NO** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch |
| `owner` | **NO** | GitHub repository owner (user or organization), defaults to the repo invoking the action. |
| `repo` | **NO** | GitHub repository name, defaults to the repo invoking the action. |
| `branch-name` | **NO*** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch. **REQUIRED:** If triggered through `on tags`.|
| `branch-push-force` | **NO** | `--force` flag when running `git push <branch-name>`. |
| `tag` | **NO** | Push tag for the new/current commit. |
| `tag-only-if-file-changes` | **NO** | Push tag for new commit only when file changes present. **DEFAULT:** true |
Expand All@@ -75,9 +76,18 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `commit-sha` | Full SHA of the signed commit. |
| `tag` | Tag of the signed commit. |

## Release

This project follows [Conventional Commits](https://www.conventionalcommits.org/) and uses a manual release workflow.

1. Ensure `dist/` is up-to-date by running `npm run bundle`
2. Trigger the **Release** workflow via `workflow_dispatch` with the desired [semver](https://semver.org/) version
- The workflow bumps `package.json`, creates a signed commit, and tags `v{version}`
3. The **Changelog** workflow automatically regenerates `CHANGELOG.md` from conventional commits using [git-cliff](https://git-cliff.org/)

[ci_badge]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml/badge.svg
[ci_workflows]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml
[coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2
[coverage]: https://codecov.io/gh/ryancyq/github-signed-commit
[maintainability_badge]: https://api.codeclimate.com/v1/badges/0de9dbec270ca85719c6/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
17 changes: 17 additions & 0 deletions __tests__/blob.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,23 @@ describe('Blob', () => {
})
})

it('binary file successfully', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0xff, 0xfe, 0x00, 0x80,
0xc0, 0xc1, 0xf5, 0xf6,
])
const binaryPath = join(__dirname, 'fixtures', 'blob.bin')
fs.writeFileSync(binaryPath, binaryContent)

try {
const blob = getBlob('fixtures/blob.bin')
const fileAddition = await blob.load()
expect(fileAddition.contents).toEqual(binaryContent.toString('base64'))
} finally {
fs.unlinkSync(binaryPath)
}
})

it('stream with error', async () => {
const blob = getBlob('fixtures/error.txt')
const mockStream = new PassThrough()
Expand Down
4 changes: 2 additions & 2 deletions __tests__/git.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -182,7 +182,7 @@ describe('Git CLI', () => {

describe('git add', () => {
beforeEach(() => {
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('/test-workspace')
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('test-workspace/')
})

it('should ensure file paths are within curent working directory', async () => {
Expand All@@ -191,7 +191,7 @@ describe('Git CLI', () => {
await addFileChanges(['*.ts', '~/.bashrc'])
expect(execMock).toHaveBeenCalledWith(
'git',
['add', '--', '/test-workspace/*.ts', '/test-workspace/~/.bashrc'],
['add', '--', 'test-workspace/*.ts', 'test-workspace/~/.bashrc'],
expect.objectContaining({
listeners: { stdline: expect.anything(), errline: expect.anything() },
})
Expand Down
36 changes: 0 additions & 36 deletions __tests__/main.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,42 +205,6 @@ describe('action', () => {
})
})

describe('input repository is given', () => {
describe('valid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user/the-repo'
return ''
})
})

it('succeed', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Neither files nor tag input has been configured'
)
})
})

describe('invalid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user-the-repo'
return ''
})
})

it('fails', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Input <repository> "the-user-the-repo" is invalid'
)
})
})
})

describe('input branch is given', () => {
beforeEach(() => {
jest.spyOn(core, 'getMultilineInput').mockReturnValue(['/test.txt'])
Expand Down
14 changes: 14 additions & 0 deletions __tests__/stream/base64-encoder.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,4 +15,18 @@ describe('Base64 Encoder', () => {
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(Buffer.from(content).toString('base64'))
})

it('binary buffer stream', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0xff, 0xfe, 0x00, 0x80, 0xc0, 0xc1,
])
const stream = Readable.from(binaryContent).pipe(new Base64Encoder())

const chunks: Buffer[] = []
for await (const chunk of stream) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
}
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(binaryContent.toString('base64'))
})
})
14 changes: 11 additions & 3 deletions action.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,15 +15,23 @@ inputs:
Directory containing files to be committed. Default: GitHub workspace directory (root of repository).
required: false
default: ''
workdir:
description: |
Directory where the action should run. Default: GitHub workspace directory (root of repository from where the GH Workflow is triggered).
required: false
default: ''
commit-message:
description: |
Commit message for the file changes.
required: false
repository:
owner:
description: |
Repository name including owner (e.g. owner/repo). Default: Workflow triggered repository.
GitHub repository owner (user or organization), defaults to the repo invoking the action.
required: false
repo:
description: |
GitHub repository name, defaults to the repo invoking the action.
required: false
default: ''
branch-name:
description: |
Branch to commit to. Default: Workflow triggered branch.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat: Add support for remote GitHub repository + working directory (#2) by xakraz · Pull Request #211 · ryancyq/github-signed-commit · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,11 @@
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

---
## [Unreleased](https://github.com/ryancyq/github-signed-commit/tree/HEAD)
## [1.3.0](https://github.com/ryancyq/github-signed-commit/compare/v1.2.0..v1.3.0) - 2024-10-30

### Features

- Add support for remote GitHub repository + working directory ([#2](https://github.com/ryancyq/github-signed-commit/issues/2)) - ([2c19408](https://github.com/ryancyq/github-signed-commit/commit/2c19408618f096a6064093809288c28e3f4daaa1)) - Xavier Krantz

### Documentation

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,8 +63,9 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `files` | **YES** | Multi-line string of file paths to be committed, relative to the current workspace.|
| `workspace` | **NO** | Directory containing files to be committed. **DEFAULT:** GitHub workspace directory (root of the repository). |
| `commit-message` | **YES** | Commit message for the file changes. |
| `repository` | **NO** | Repository name including owner (e.g. owner/repo). **DEFAULT:** Workflow triggered repository |
| `branch-name` | **NO** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch |
| `owner` | **NO** | GitHub repository owner (user or organization), defaults to the repo invoking the action. |
| `repo` | **NO** | GitHub repository name, defaults to the repo invoking the action. |
| `branch-name` | **NO*** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch. **REQUIRED:** If triggered through `on tags`.|
| `branch-push-force` | **NO** | `--force` flag when running `git push <branch-name>`. |
| `tag` | **NO** | Push tag for the new/current commit. |
| `tag-only-if-file-changes` | **NO** | Push tag for new commit only when file changes present. **DEFAULT:** true |
Expand All@@ -75,9 +76,18 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `commit-sha` | Full SHA of the signed commit. |
| `tag` | Tag of the signed commit. |

## Release

This project follows [Conventional Commits](https://www.conventionalcommits.org/) and uses a manual release workflow.

1. Ensure `dist/` is up-to-date by running `npm run bundle`
2. Trigger the **Release** workflow via `workflow_dispatch` with the desired [semver](https://semver.org/) version
- The workflow bumps `package.json`, creates a signed commit, and tags `v{version}`
3. The **Changelog** workflow automatically regenerates `CHANGELOG.md` from conventional commits using [git-cliff](https://git-cliff.org/)

[ci_badge]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml/badge.svg
[ci_workflows]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml
[coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2
[coverage]: https://codecov.io/gh/ryancyq/github-signed-commit
[maintainability_badge]: https://api.codeclimate.com/v1/badges/0de9dbec270ca85719c6/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
17 changes: 17 additions & 0 deletions __tests__/blob.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,23 @@ describe('Blob', () => {
})
})

it('binary file successfully', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0xff, 0xfe, 0x00, 0x80,
0xc0, 0xc1, 0xf5, 0xf6,
])
const binaryPath = join(__dirname, 'fixtures', 'blob.bin')
fs.writeFileSync(binaryPath, binaryContent)

try {
const blob = getBlob('fixtures/blob.bin')
const fileAddition = await blob.load()
expect(fileAddition.contents).toEqual(binaryContent.toString('base64'))
} finally {
fs.unlinkSync(binaryPath)
}
})

it('stream with error', async () => {
const blob = getBlob('fixtures/error.txt')
const mockStream = new PassThrough()
Expand Down
4 changes: 2 additions & 2 deletions __tests__/git.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -182,7 +182,7 @@ describe('Git CLI', () => {

describe('git add', () => {
beforeEach(() => {
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('/test-workspace')
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('test-workspace/')
})

it('should ensure file paths are within curent working directory', async () => {
Expand All@@ -191,7 +191,7 @@ describe('Git CLI', () => {
await addFileChanges(['*.ts', '~/.bashrc'])
expect(execMock).toHaveBeenCalledWith(
'git',
['add', '--', '/test-workspace/*.ts', '/test-workspace/~/.bashrc'],
['add', '--', 'test-workspace/*.ts', 'test-workspace/~/.bashrc'],
expect.objectContaining({
listeners: { stdline: expect.anything(), errline: expect.anything() },
})
Expand Down
36 changes: 0 additions & 36 deletions __tests__/main.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,42 +205,6 @@ describe('action', () => {
})
})

describe('input repository is given', () => {
describe('valid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user/the-repo'
return ''
})
})

it('succeed', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Neither files nor tag input has been configured'
)
})
})

describe('invalid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user-the-repo'
return ''
})
})

it('fails', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Input <repository> "the-user-the-repo" is invalid'
)
})
})
})

describe('input branch is given', () => {
beforeEach(() => {
jest.spyOn(core, 'getMultilineInput').mockReturnValue(['/test.txt'])
Expand Down
14 changes: 14 additions & 0 deletions __tests__/stream/base64-encoder.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,4 +15,18 @@ describe('Base64 Encoder', () => {
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(Buffer.from(content).toString('base64'))
})

it('binary buffer stream', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0xff, 0xfe, 0x00, 0x80, 0xc0, 0xc1,
])
const stream = Readable.from(binaryContent).pipe(new Base64Encoder())

const chunks: Buffer[] = []
for await (const chunk of stream) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
}
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(binaryContent.toString('base64'))
})
})
14 changes: 11 additions & 3 deletions action.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,15 +15,23 @@ inputs:
Directory containing files to be committed. Default: GitHub workspace directory (root of repository).
required: false
default: ''
workdir:
description: |
Directory where the action should run. Default: GitHub workspace directory (root of repository from where the GH Workflow is triggered).
required: false
default: ''
commit-message:
description: |
Commit message for the file changes.
required: false
repository:
owner:
description: |
Repository name including owner (e.g. owner/repo). Default: Workflow triggered repository.
GitHub repository owner (user or organization), defaults to the repo invoking the action.
required: false
repo:
description: |
GitHub repository name, defaults to the repo invoking the action.
required: false
default: ''
branch-name:
description: |
Branch to commit to. Default: Workflow triggered branch.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat: Add support for remote GitHub repository + working directory (#2) by xakraz · Pull Request #211 · ryancyq/github-signed-commit · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,11 @@
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

---
## [Unreleased](https://github.com/ryancyq/github-signed-commit/tree/HEAD)
## [1.3.0](https://github.com/ryancyq/github-signed-commit/compare/v1.2.0..v1.3.0) - 2024-10-30

### Features

- Add support for remote GitHub repository + working directory ([#2](https://github.com/ryancyq/github-signed-commit/issues/2)) - ([2c19408](https://github.com/ryancyq/github-signed-commit/commit/2c19408618f096a6064093809288c28e3f4daaa1)) - Xavier Krantz

### Documentation

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,8 +63,9 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `files` | **YES** | Multi-line string of file paths to be committed, relative to the current workspace.|
| `workspace` | **NO** | Directory containing files to be committed. **DEFAULT:** GitHub workspace directory (root of the repository). |
| `commit-message` | **YES** | Commit message for the file changes. |
| `repository` | **NO** | Repository name including owner (e.g. owner/repo). **DEFAULT:** Workflow triggered repository |
| `branch-name` | **NO** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch |
| `owner` | **NO** | GitHub repository owner (user or organization), defaults to the repo invoking the action. |
| `repo` | **NO** | GitHub repository name, defaults to the repo invoking the action. |
| `branch-name` | **NO*** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch. **REQUIRED:** If triggered through `on tags`.|
| `branch-push-force` | **NO** | `--force` flag when running `git push <branch-name>`. |
| `tag` | **NO** | Push tag for the new/current commit. |
| `tag-only-if-file-changes` | **NO** | Push tag for new commit only when file changes present. **DEFAULT:** true |
Expand All@@ -75,9 +76,18 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `commit-sha` | Full SHA of the signed commit. |
| `tag` | Tag of the signed commit. |

## Release

This project follows [Conventional Commits](https://www.conventionalcommits.org/) and uses a manual release workflow.

1. Ensure `dist/` is up-to-date by running `npm run bundle`
2. Trigger the **Release** workflow via `workflow_dispatch` with the desired [semver](https://semver.org/) version
- The workflow bumps `package.json`, creates a signed commit, and tags `v{version}`
3. The **Changelog** workflow automatically regenerates `CHANGELOG.md` from conventional commits using [git-cliff](https://git-cliff.org/)

[ci_badge]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml/badge.svg
[ci_workflows]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml
[coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2
[coverage]: https://codecov.io/gh/ryancyq/github-signed-commit
[maintainability_badge]: https://api.codeclimate.com/v1/badges/0de9dbec270ca85719c6/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
17 changes: 17 additions & 0 deletions __tests__/blob.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,23 @@ describe('Blob', () => {
})
})

it('binary file successfully', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0xff, 0xfe, 0x00, 0x80,
0xc0, 0xc1, 0xf5, 0xf6,
])
const binaryPath = join(__dirname, 'fixtures', 'blob.bin')
fs.writeFileSync(binaryPath, binaryContent)

try {
const blob = getBlob('fixtures/blob.bin')
const fileAddition = await blob.load()
expect(fileAddition.contents).toEqual(binaryContent.toString('base64'))
} finally {
fs.unlinkSync(binaryPath)
}
})

it('stream with error', async () => {
const blob = getBlob('fixtures/error.txt')
const mockStream = new PassThrough()
Expand Down
4 changes: 2 additions & 2 deletions __tests__/git.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -182,7 +182,7 @@ describe('Git CLI', () => {

describe('git add', () => {
beforeEach(() => {
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('/test-workspace')
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('test-workspace/')
})

it('should ensure file paths are within curent working directory', async () => {
Expand All@@ -191,7 +191,7 @@ describe('Git CLI', () => {
await addFileChanges(['*.ts', '~/.bashrc'])
expect(execMock).toHaveBeenCalledWith(
'git',
['add', '--', '/test-workspace/*.ts', '/test-workspace/~/.bashrc'],
['add', '--', 'test-workspace/*.ts', 'test-workspace/~/.bashrc'],
expect.objectContaining({
listeners: { stdline: expect.anything(), errline: expect.anything() },
})
Expand Down
36 changes: 0 additions & 36 deletions __tests__/main.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,42 +205,6 @@ describe('action', () => {
})
})

describe('input repository is given', () => {
describe('valid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user/the-repo'
return ''
})
})

it('succeed', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Neither files nor tag input has been configured'
)
})
})

describe('invalid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user-the-repo'
return ''
})
})

it('fails', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Input <repository> "the-user-the-repo" is invalid'
)
})
})
})

describe('input branch is given', () => {
beforeEach(() => {
jest.spyOn(core, 'getMultilineInput').mockReturnValue(['/test.txt'])
Expand Down
14 changes: 14 additions & 0 deletions __tests__/stream/base64-encoder.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,4 +15,18 @@ describe('Base64 Encoder', () => {
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(Buffer.from(content).toString('base64'))
})

it('binary buffer stream', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0xff, 0xfe, 0x00, 0x80, 0xc0, 0xc1,
])
const stream = Readable.from(binaryContent).pipe(new Base64Encoder())

const chunks: Buffer[] = []
for await (const chunk of stream) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
}
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(binaryContent.toString('base64'))
})
})
14 changes: 11 additions & 3 deletions action.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,15 +15,23 @@ inputs:
Directory containing files to be committed. Default: GitHub workspace directory (root of repository).
required: false
default: ''
workdir:
description: |
Directory where the action should run. Default: GitHub workspace directory (root of repository from where the GH Workflow is triggered).
required: false
default: ''
commit-message:
description: |
Commit message for the file changes.
required: false
repository:
owner:
description: |
Repository name including owner (e.g. owner/repo). Default: Workflow triggered repository.
GitHub repository owner (user or organization), defaults to the repo invoking the action.
required: false
repo:
description: |
GitHub repository name, defaults to the repo invoking the action.
required: false
default: ''
branch-name:
description: |
Branch to commit to. Default: Workflow triggered branch.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' feat: Add support for remote GitHub repository + working directory (#2) by xakraz · Pull Request #211 · ryancyq/github-signed-commit · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,11 @@
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

---
## [Unreleased](https://github.com/ryancyq/github-signed-commit/tree/HEAD)
## [1.3.0](https://github.com/ryancyq/github-signed-commit/compare/v1.2.0..v1.3.0) - 2024-10-30

### Features

- Add support for remote GitHub repository + working directory ([#2](https://github.com/ryancyq/github-signed-commit/issues/2)) - ([2c19408](https://github.com/ryancyq/github-signed-commit/commit/2c19408618f096a6064093809288c28e3f4daaa1)) - Xavier Krantz

### Documentation

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,8 +63,9 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `files` | **YES** | Multi-line string of file paths to be committed, relative to the current workspace.|
| `workspace` | **NO** | Directory containing files to be committed. **DEFAULT:** GitHub workspace directory (root of the repository). |
| `commit-message` | **YES** | Commit message for the file changes. |
| `repository` | **NO** | Repository name including owner (e.g. owner/repo). **DEFAULT:** Workflow triggered repository |
| `branch-name` | **NO** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch |
| `owner` | **NO** | GitHub repository owner (user or organization), defaults to the repo invoking the action. |
| `repo` | **NO** | GitHub repository name, defaults to the repo invoking the action. |
| `branch-name` | **NO*** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch. **REQUIRED:** If triggered through `on tags`.|
| `branch-push-force` | **NO** | `--force` flag when running `git push <branch-name>`. |
| `tag` | **NO** | Push tag for the new/current commit. |
| `tag-only-if-file-changes` | **NO** | Push tag for new commit only when file changes present. **DEFAULT:** true |
Expand All@@ -75,9 +76,18 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `commit-sha` | Full SHA of the signed commit. |
| `tag` | Tag of the signed commit. |

## Release

This project follows [Conventional Commits](https://www.conventionalcommits.org/) and uses a manual release workflow.

1. Ensure `dist/` is up-to-date by running `npm run bundle`
2. Trigger the **Release** workflow via `workflow_dispatch` with the desired [semver](https://semver.org/) version
- The workflow bumps `package.json`, creates a signed commit, and tags `v{version}`
3. The **Changelog** workflow automatically regenerates `CHANGELOG.md` from conventional commits using [git-cliff](https://git-cliff.org/)

[ci_badge]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml/badge.svg
[ci_workflows]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml
[coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2
[coverage]: https://codecov.io/gh/ryancyq/github-signed-commit
[maintainability_badge]: https://api.codeclimate.com/v1/badges/0de9dbec270ca85719c6/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
17 changes: 17 additions & 0 deletions __tests__/blob.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,23 @@ describe('Blob', () => {
})
})

it('binary file successfully', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0xff, 0xfe, 0x00, 0x80,
0xc0, 0xc1, 0xf5, 0xf6,
])
const binaryPath = join(__dirname, 'fixtures', 'blob.bin')
fs.writeFileSync(binaryPath, binaryContent)

try {
const blob = getBlob('fixtures/blob.bin')
const fileAddition = await blob.load()
expect(fileAddition.contents).toEqual(binaryContent.toString('base64'))
} finally {
fs.unlinkSync(binaryPath)
}
})

it('stream with error', async () => {
const blob = getBlob('fixtures/error.txt')
const mockStream = new PassThrough()
Expand Down
4 changes: 2 additions & 2 deletions __tests__/git.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -182,7 +182,7 @@ describe('Git CLI', () => {

describe('git add', () => {
beforeEach(() => {
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('/test-workspace')
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('test-workspace/')
})

it('should ensure file paths are within curent working directory', async () => {
Expand All@@ -191,7 +191,7 @@ describe('Git CLI', () => {
await addFileChanges(['*.ts', '~/.bashrc'])
expect(execMock).toHaveBeenCalledWith(
'git',
['add', '--', '/test-workspace/*.ts', '/test-workspace/~/.bashrc'],
['add', '--', 'test-workspace/*.ts', 'test-workspace/~/.bashrc'],
expect.objectContaining({
listeners: { stdline: expect.anything(), errline: expect.anything() },
})
Expand Down
36 changes: 0 additions & 36 deletions __tests__/main.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,42 +205,6 @@ describe('action', () => {
})
})

describe('input repository is given', () => {
describe('valid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user/the-repo'
return ''
})
})

it('succeed', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Neither files nor tag input has been configured'
)
})
})

describe('invalid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user-the-repo'
return ''
})
})

it('fails', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Input <repository> "the-user-the-repo" is invalid'
)
})
})
})

describe('input branch is given', () => {
beforeEach(() => {
jest.spyOn(core, 'getMultilineInput').mockReturnValue(['/test.txt'])
Expand Down
14 changes: 14 additions & 0 deletions __tests__/stream/base64-encoder.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,4 +15,18 @@ describe('Base64 Encoder', () => {
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(Buffer.from(content).toString('base64'))
})

it('binary buffer stream', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0xff, 0xfe, 0x00, 0x80, 0xc0, 0xc1,
])
const stream = Readable.from(binaryContent).pipe(new Base64Encoder())

const chunks: Buffer[] = []
for await (const chunk of stream) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
}
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(binaryContent.toString('base64'))
})
})
14 changes: 11 additions & 3 deletions action.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,15 +15,23 @@ inputs:
Directory containing files to be committed. Default: GitHub workspace directory (root of repository).
required: false
default: ''
workdir:
description: |
Directory where the action should run. Default: GitHub workspace directory (root of repository from where the GH Workflow is triggered).
required: false
default: ''
commit-message:
description: |
Commit message for the file changes.
required: false
repository:
owner:
description: |
Repository name including owner (e.g. owner/repo). Default: Workflow triggered repository.
GitHub repository owner (user or organization), defaults to the repo invoking the action.
required: false
repo:
description: |
GitHub repository name, defaults to the repo invoking the action.
required: false
default: ''
branch-name:
description: |
Branch to commit to. Default: Workflow triggered branch.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat: Add support for remote GitHub repository + working directory (#2) by xakraz · Pull Request #211 · ryancyq/github-signed-commit · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,11 @@
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

---
## [Unreleased](https://github.com/ryancyq/github-signed-commit/tree/HEAD)
## [1.3.0](https://github.com/ryancyq/github-signed-commit/compare/v1.2.0..v1.3.0) - 2024-10-30

### Features

- Add support for remote GitHub repository + working directory ([#2](https://github.com/ryancyq/github-signed-commit/issues/2)) - ([2c19408](https://github.com/ryancyq/github-signed-commit/commit/2c19408618f096a6064093809288c28e3f4daaa1)) - Xavier Krantz

### Documentation

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,8 +63,9 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `files` | **YES** | Multi-line string of file paths to be committed, relative to the current workspace.|
| `workspace` | **NO** | Directory containing files to be committed. **DEFAULT:** GitHub workspace directory (root of the repository). |
| `commit-message` | **YES** | Commit message for the file changes. |
| `repository` | **NO** | Repository name including owner (e.g. owner/repo). **DEFAULT:** Workflow triggered repository |
| `branch-name` | **NO** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch |
| `owner` | **NO** | GitHub repository owner (user or organization), defaults to the repo invoking the action. |
| `repo` | **NO** | GitHub repository name, defaults to the repo invoking the action. |
| `branch-name` | **NO*** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch. **REQUIRED:** If triggered through `on tags`.|
| `branch-push-force` | **NO** | `--force` flag when running `git push <branch-name>`. |
| `tag` | **NO** | Push tag for the new/current commit. |
| `tag-only-if-file-changes` | **NO** | Push tag for new commit only when file changes present. **DEFAULT:** true |
Expand All@@ -75,9 +76,18 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `commit-sha` | Full SHA of the signed commit. |
| `tag` | Tag of the signed commit. |

## Release

This project follows [Conventional Commits](https://www.conventionalcommits.org/) and uses a manual release workflow.

1. Ensure `dist/` is up-to-date by running `npm run bundle`
2. Trigger the **Release** workflow via `workflow_dispatch` with the desired [semver](https://semver.org/) version
- The workflow bumps `package.json`, creates a signed commit, and tags `v{version}`
3. The **Changelog** workflow automatically regenerates `CHANGELOG.md` from conventional commits using [git-cliff](https://git-cliff.org/)

[ci_badge]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml/badge.svg
[ci_workflows]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml
[coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2
[coverage]: https://codecov.io/gh/ryancyq/github-signed-commit
[maintainability_badge]: https://api.codeclimate.com/v1/badges/0de9dbec270ca85719c6/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
17 changes: 17 additions & 0 deletions __tests__/blob.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,23 @@ describe('Blob', () => {
})
})

it('binary file successfully', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0xff, 0xfe, 0x00, 0x80,
0xc0, 0xc1, 0xf5, 0xf6,
])
const binaryPath = join(__dirname, 'fixtures', 'blob.bin')
fs.writeFileSync(binaryPath, binaryContent)

try {
const blob = getBlob('fixtures/blob.bin')
const fileAddition = await blob.load()
expect(fileAddition.contents).toEqual(binaryContent.toString('base64'))
} finally {
fs.unlinkSync(binaryPath)
}
})

it('stream with error', async () => {
const blob = getBlob('fixtures/error.txt')
const mockStream = new PassThrough()
Expand Down
4 changes: 2 additions & 2 deletions __tests__/git.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -182,7 +182,7 @@ describe('Git CLI', () => {

describe('git add', () => {
beforeEach(() => {
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('/test-workspace')
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('test-workspace/')
})

it('should ensure file paths are within curent working directory', async () => {
Expand All@@ -191,7 +191,7 @@ describe('Git CLI', () => {
await addFileChanges(['*.ts', '~/.bashrc'])
expect(execMock).toHaveBeenCalledWith(
'git',
['add', '--', '/test-workspace/*.ts', '/test-workspace/~/.bashrc'],
['add', '--', 'test-workspace/*.ts', 'test-workspace/~/.bashrc'],
expect.objectContaining({
listeners: { stdline: expect.anything(), errline: expect.anything() },
})
Expand Down
36 changes: 0 additions & 36 deletions __tests__/main.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,42 +205,6 @@ describe('action', () => {
})
})

describe('input repository is given', () => {
describe('valid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user/the-repo'
return ''
})
})

it('succeed', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Neither files nor tag input has been configured'
)
})
})

describe('invalid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user-the-repo'
return ''
})
})

it('fails', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Input <repository> "the-user-the-repo" is invalid'
)
})
})
})

describe('input branch is given', () => {
beforeEach(() => {
jest.spyOn(core, 'getMultilineInput').mockReturnValue(['/test.txt'])
Expand Down
14 changes: 14 additions & 0 deletions __tests__/stream/base64-encoder.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,4 +15,18 @@ describe('Base64 Encoder', () => {
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(Buffer.from(content).toString('base64'))
})

it('binary buffer stream', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0xff, 0xfe, 0x00, 0x80, 0xc0, 0xc1,
])
const stream = Readable.from(binaryContent).pipe(new Base64Encoder())

const chunks: Buffer[] = []
for await (const chunk of stream) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
}
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(binaryContent.toString('base64'))
})
})
14 changes: 11 additions & 3 deletions action.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,15 +15,23 @@ inputs:
Directory containing files to be committed. Default: GitHub workspace directory (root of repository).
required: false
default: ''
workdir:
description: |
Directory where the action should run. Default: GitHub workspace directory (root of repository from where the GH Workflow is triggered).
required: false
default: ''
commit-message:
description: |
Commit message for the file changes.
required: false
repository:
owner:
description: |
Repository name including owner (e.g. owner/repo). Default: Workflow triggered repository.
GitHub repository owner (user or organization), defaults to the repo invoking the action.
required: false
repo:
description: |
GitHub repository name, defaults to the repo invoking the action.
required: false
default: ''
branch-name:
description: |
Branch to commit to. Default: Workflow triggered branch.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); feat: Add support for remote GitHub repository + working directory (#2) by xakraz · Pull Request #211 · ryancyq/github-signed-commit · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,11 @@
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

---
## [Unreleased](https://github.com/ryancyq/github-signed-commit/tree/HEAD)
## [1.3.0](https://github.com/ryancyq/github-signed-commit/compare/v1.2.0..v1.3.0) - 2024-10-30

### Features

- Add support for remote GitHub repository + working directory ([#2](https://github.com/ryancyq/github-signed-commit/issues/2)) - ([2c19408](https://github.com/ryancyq/github-signed-commit/commit/2c19408618f096a6064093809288c28e3f4daaa1)) - Xavier Krantz

### Documentation

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,8 +63,9 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `files` | **YES** | Multi-line string of file paths to be committed, relative to the current workspace.|
| `workspace` | **NO** | Directory containing files to be committed. **DEFAULT:** GitHub workspace directory (root of the repository). |
| `commit-message` | **YES** | Commit message for the file changes. |
| `repository` | **NO** | Repository name including owner (e.g. owner/repo). **DEFAULT:** Workflow triggered repository |
| `branch-name` | **NO** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch |
| `owner` | **NO** | GitHub repository owner (user or organization), defaults to the repo invoking the action. |
| `repo` | **NO** | GitHub repository name, defaults to the repo invoking the action. |
| `branch-name` | **NO*** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch. **REQUIRED:** If triggered through `on tags`.|
| `branch-push-force` | **NO** | `--force` flag when running `git push <branch-name>`. |
| `tag` | **NO** | Push tag for the new/current commit. |
| `tag-only-if-file-changes` | **NO** | Push tag for new commit only when file changes present. **DEFAULT:** true |
Expand All@@ -75,9 +76,18 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `commit-sha` | Full SHA of the signed commit. |
| `tag` | Tag of the signed commit. |

## Release

This project follows [Conventional Commits](https://www.conventionalcommits.org/) and uses a manual release workflow.

1. Ensure `dist/` is up-to-date by running `npm run bundle`
2. Trigger the **Release** workflow via `workflow_dispatch` with the desired [semver](https://semver.org/) version
- The workflow bumps `package.json`, creates a signed commit, and tags `v{version}`
3. The **Changelog** workflow automatically regenerates `CHANGELOG.md` from conventional commits using [git-cliff](https://git-cliff.org/)

[ci_badge]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml/badge.svg
[ci_workflows]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml
[coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2
[coverage]: https://codecov.io/gh/ryancyq/github-signed-commit
[maintainability_badge]: https://api.codeclimate.com/v1/badges/0de9dbec270ca85719c6/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
17 changes: 17 additions & 0 deletions __tests__/blob.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,23 @@ describe('Blob', () => {
})
})

it('binary file successfully', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0xff, 0xfe, 0x00, 0x80,
0xc0, 0xc1, 0xf5, 0xf6,
])
const binaryPath = join(__dirname, 'fixtures', 'blob.bin')
fs.writeFileSync(binaryPath, binaryContent)

try {
const blob = getBlob('fixtures/blob.bin')
const fileAddition = await blob.load()
expect(fileAddition.contents).toEqual(binaryContent.toString('base64'))
} finally {
fs.unlinkSync(binaryPath)
}
})

it('stream with error', async () => {
const blob = getBlob('fixtures/error.txt')
const mockStream = new PassThrough()
Expand Down
4 changes: 2 additions & 2 deletions __tests__/git.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -182,7 +182,7 @@ describe('Git CLI', () => {

describe('git add', () => {
beforeEach(() => {
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('/test-workspace')
jest.spyOn(cwd, 'getWorkspace').mockReturnValue('test-workspace/')
})

it('should ensure file paths are within curent working directory', async () => {
Expand All@@ -191,7 +191,7 @@ describe('Git CLI', () => {
await addFileChanges(['*.ts', '~/.bashrc'])
expect(execMock).toHaveBeenCalledWith(
'git',
['add', '--', '/test-workspace/*.ts', '/test-workspace/~/.bashrc'],
['add', '--', 'test-workspace/*.ts', 'test-workspace/~/.bashrc'],
expect.objectContaining({
listeners: { stdline: expect.anything(), errline: expect.anything() },
})
Expand Down
36 changes: 0 additions & 36 deletions __tests__/main.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,42 +205,6 @@ describe('action', () => {
})
})

describe('input repository is given', () => {
describe('valid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user/the-repo'
return ''
})
})

it('succeed', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Neither files nor tag input has been configured'
)
})
})

describe('invalid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user-the-repo'
return ''
})
})

it('fails', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Input <repository> "the-user-the-repo" is invalid'
)
})
})
})

describe('input branch is given', () => {
beforeEach(() => {
jest.spyOn(core, 'getMultilineInput').mockReturnValue(['/test.txt'])
Expand Down
14 changes: 14 additions & 0 deletions __tests__/stream/base64-encoder.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,4 +15,18 @@ describe('Base64 Encoder', () => {
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(Buffer.from(content).toString('base64'))
})

it('binary buffer stream', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0xff, 0xfe, 0x00, 0x80, 0xc0, 0xc1,
])
const stream = Readable.from(binaryContent).pipe(new Base64Encoder())

const chunks: Buffer[] = []
for await (const chunk of stream) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
}
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(binaryContent.toString('base64'))
})
})
14 changes: 11 additions & 3 deletions action.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,15 +15,23 @@ inputs:
Directory containing files to be committed. Default: GitHub workspace directory (root of repository).
required: false
default: ''
workdir:
description: |
Directory where the action should run. Default: GitHub workspace directory (root of repository from where the GH Workflow is triggered).
required: false
default: ''
commit-message:
description: |
Commit message for the file changes.
required: false
repository:
owner:
description: |
Repository name including owner (e.g. owner/repo). Default: Workflow triggered repository.
GitHub repository owner (user or organization), defaults to the repo invoking the action.
required: false
repo:
description: |
GitHub repository name, defaults to the repo invoking the action.
required: false
default: ''
branch-name:
description: |
Branch to commit to. Default: Workflow triggered branch.
Expand Down
Loading