Merge pull request 'fix(action image): 安裝 git 供前置遠端驗證使用' (#7) from develop into master
CD / Release Tag Version (push) Failing after 0s
CD / Release Tag Version (push) Failing after 0s
Reviewed-on: docker-actions/ai-code-review#7 Reviewed-by: 系統管理員 <1+admin@noreply.localhost>
This commit was merged in pull request #7.
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
# 安裝必要的工具
|
# 安裝必要的工具
|
||||||
RUN apk add --no-cache --no-check-certificate bash nodejs npm
|
RUN apk add --no-cache --no-check-certificate bash git nodejs npm
|
||||||
|
|
||||||
COPY ./app /app
|
COPY ./app /app
|
||||||
RUN cd /app && npm install
|
RUN cd /app && npm install
|
||||||
@@ -9,4 +9,4 @@ RUN cd /app && npm install
|
|||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|||||||
+4
-1
@@ -13,7 +13,10 @@ function makeRunner(spawn) {
|
|||||||
const opts = { cwd, encoding: 'utf8' };
|
const opts = { cwd, encoding: 'utf8' };
|
||||||
if (env) opts.env = env;
|
if (env) opts.env = env;
|
||||||
const result = spawn('git', args, opts);
|
const result = spawn('git', args, opts);
|
||||||
if (result.error) throw result.error;
|
if (result.error) {
|
||||||
|
if (result.error.code === 'ENOENT') throw new Error('找不到 git 指令,請確認 action image 已安裝 git');
|
||||||
|
throw result.error;
|
||||||
|
}
|
||||||
if (result.status !== 0) throw new Error((result.stderr || result.stdout || '').trim());
|
if (result.status !== 0) throw new Error((result.stderr || result.stdout || '').trim());
|
||||||
return (result.stdout || '').trim();
|
return (result.stdout || '').trim();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -300,6 +300,15 @@ describe('verifyRemoteAccess', () => {
|
|||||||
assert.match(result.error, /could not read Username/);
|
assert.match(result.error, /could not read Username/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('reports a clear failure when git is not installed', () => {
|
||||||
|
const enoent = new Error('spawnSync git ENOENT');
|
||||||
|
enoent.code = 'ENOENT';
|
||||||
|
const spawn = () => ({ status: null, stdout: '', stderr: '', error: enoent });
|
||||||
|
const result = verifyRemoteAccess(workspace, spawn);
|
||||||
|
assert.equal(result.ok, false);
|
||||||
|
assert.match(result.error, /找不到 git 指令/);
|
||||||
|
});
|
||||||
|
|
||||||
it('cleans up the askpass script after running', () => {
|
it('cleans up the askpass script after running', () => {
|
||||||
verifyRemoteAccess(workspace, () => ({ status: 0, stdout: '', stderr: '', error: null }));
|
verifyRemoteAccess(workspace, () => ({ status: 0, stdout: '', stderr: '', error: null }));
|
||||||
const leftover = fs.readdirSync(workspace).filter(f => f.endsWith('.git-askpass.sh'));
|
const leftover = fs.readdirSync(workspace).filter(f => f.endsWith('.git-askpass.sh'));
|
||||||
|
|||||||
Reference in New Issue
Block a user