Skip to content

Commit

Permalink
Fix action runner initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ggodlewski committed Oct 24, 2023
1 parent 9093878 commit 8c87647
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions apps/wgd-action-runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RUN npm i -g postcss postcss-cli hugo-extended
RUN git clone https://github.com/budparr/gohugo-theme-ananke.git /themes/ananke

RUN git init /site
RUN git config --global --add safe.directory /site

ADD steps/ /steps
RUN chmod a+x /steps/step_*
9 changes: 7 additions & 2 deletions src/containers/action/ActionRunnerContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export class ActionRunnerContainer extends Container {
}, step.env, additionalEnv) : Object.assign({}, step.env, additionalEnv);

this.logger.info(`DockerAPI:\ndocker run \\
--user=${process.getuid()} \\
-v "${process.env.VOLUME_DATA}/${driveId}_transform:/repo" \\
-v "${process.env.VOLUME_DATA}${contentDir}:/site/content" \\
-v "${process.env.VOLUME_PREVIEW}/${driveId}/${themeId}:/site/public" \\
Expand All @@ -181,7 +182,8 @@ export class ActionRunnerContainer extends Container {
`${process.env.VOLUME_DATA}/${driveId}/tmp_dir:/site/resources`
]
},
Env: Object.keys(env).map(key => `${key}=${env[key]}`)
Env: Object.keys(env).map(key => `${key}=${env[key]}`),
User: String(process.getuid())
});
} else {
const env = ['render_hugo', 'exec', 'commit_branch'].includes(step.uses) ? Object.assign({
Expand All @@ -194,6 +196,7 @@ export class ActionRunnerContainer extends Container {
}, step.env, additionalEnv) : Object.assign({}, step.env, additionalEnv);

this.logger.info(`DockerAPI:\ndocker run \\
--user=${process.getuid()} \\
-v "${process.env.VOLUME_DATA}/${driveId}_transform:/repo" \\
-v "${process.env.VOLUME_DATA}/${driveIdTransform}:/site" \\
-v "${process.env.VOLUME_DATA}${contentDir}:/site/content" \\
Expand All @@ -215,7 +218,8 @@ export class ActionRunnerContainer extends Container {
`${process.env.VOLUME_DATA}/${driveId}/tmp_dir:/site/resources`
]
},
Env: Object.keys(env).map(key => `${key}=${env[key]}`)
Env: Object.keys(env).map(key => `${key}=${env[key]}`),
User: String(process.getuid())
});
}

Expand All @@ -226,6 +230,7 @@ export class ActionRunnerContainer extends Container {
this.logger.info(writable.getBuffer().toString());
}
} catch (err) {
code = err.statusCode || 1;
this.logger.error(err.stack ? err.stack : err.message);
}
return code;
Expand Down
9 changes: 6 additions & 3 deletions src/utils/logger/JobLogFile.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Transport, {TransportStreamOptions} from 'winston-transport';
import path from 'path';
import fs, {ReadStream} from 'fs';
import os from 'os';
import {JobLogFileProcessor} from './JobLogFileProcessor';
import {StreamOptions} from 'stream';

import Transport, {TransportStreamOptions} from 'winston-transport';
import {JobLogFileProcessor} from './JobLogFileProcessor';

interface JobLogStreamOptions extends TransportStreamOptions {
file_options?: StreamOptions<ReadStream>;
Expand Down Expand Up @@ -75,6 +74,8 @@ export class JobLogFile extends Transport {
.replace('%jobId%', jobId)
.replace('//', '/');

fs.mkdirSync(dirname, { recursive: true });

const filename = path.join(dirname, this.filename)
.replace(/%JOB_ID%/g, jobId);
return fs.createWriteStream(filename, this.options.file_options);
Expand All @@ -99,6 +100,8 @@ export class JobLogFile extends Transport {
.replace('%jobId%', options.jobId)
.replace('//', '/');

fs.mkdirSync(dirname, { recursive: true });

const filename = path.join(dirname, this.filename)
.replace(/%JOB_ID%/g, options.jobId);

Expand Down

0 comments on commit 8c87647

Please sign in to comment.