From da84c6927892af8bc9651617462acbf437dd26b8 Mon Sep 17 00:00:00 2001 From: Grzegorz Godlewski Date: Sat, 23 Sep 2023 21:22:49 +0200 Subject: [PATCH] Fix first render Resolves: #364 --- apps/wgd-action-runner/Dockerfile | 1 + apps/wgd-action-runner/steps/step_render_hugo | 3 ++- src/containers/action/ActionRunnerContainer.ts | 18 ++++++++++++++++++ .../google_folder/UserConfigService.ts | 14 +++++++++++--- src/containers/job/JobManagerContainer.ts | 12 ++++++++++++ 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/apps/wgd-action-runner/Dockerfile b/apps/wgd-action-runner/Dockerfile index 257ff35c..8c842f19 100644 --- a/apps/wgd-action-runner/Dockerfile +++ b/apps/wgd-action-runner/Dockerfile @@ -6,6 +6,7 @@ ADD site/ /site ENV BASE_URL=http://example.com/ ENV THEME_ID="" ENV THEME_URL="" +ENV NO_COLOR="true" VOLUME ["/site/content"] VOLUME ["/site/public"] diff --git a/apps/wgd-action-runner/steps/step_render_hugo b/apps/wgd-action-runner/steps/step_render_hugo index 10b809b1..044a06d9 100644 --- a/apps/wgd-action-runner/steps/step_render_hugo +++ b/apps/wgd-action-runner/steps/step_render_hugo @@ -27,7 +27,8 @@ then fi cat /site/tmp_dir/config.toml -hugo --config="$CONFIG_TOML" --verbose --baseURL="$BASE_URL" +#hugo --logLevel debug --config="$CONFIG_TOML" --baseURL="$BASE_URL" +hugo --logLevel info --config="$CONFIG_TOML" --baseURL="$BASE_URL" CODE=$? diff --git a/src/containers/action/ActionRunnerContainer.ts b/src/containers/action/ActionRunnerContainer.ts index 815c3ae4..db590916 100644 --- a/src/containers/action/ActionRunnerContainer.ts +++ b/src/containers/action/ActionRunnerContainer.ts @@ -47,6 +47,24 @@ export const DEFAULT_ACTIONS: ActionDefinition[] = [ uses: 'push_branch' } ] + }, + { + on: 'git_reset', + steps: [ + { + name: 'render_hugo', + uses: 'render_hugo', + } + ] + }, + { + on: 'git_pull', + steps: [ + { + name: 'render_hugo', + uses: 'render_hugo', + } + ] } ]; diff --git a/src/containers/google_folder/UserConfigService.ts b/src/containers/google_folder/UserConfigService.ts index 32d96294..0c8c6a32 100644 --- a/src/containers/google_folder/UserConfigService.ts +++ b/src/containers/google_folder/UserConfigService.ts @@ -42,6 +42,16 @@ export class UserConfig { actions_yaml?: string; } +const DEFAULT_CONFIG: UserConfig = { + remote_branch: 'master', + hugo_theme: { + id: 'ananke', + name: 'Anake', + url: 'https://github.com/budparr/gohugo-theme-ananke.git', + preview_img: 'https://raw.githubusercontent.com/budparr/gohugo-theme-ananke/master/images/screenshot.png' + } +}; + export class UserConfigService { public config: UserConfig; @@ -53,9 +63,7 @@ export class UserConfigService { const json = await this.fileService.readJson('.user_config.json'); this.config = json || {}; } else { - this.config = { - remote_branch: 'master' - }; + this.config = structuredClone(DEFAULT_CONFIG); await this.save(); } if (!this.config.actions_yaml) { diff --git a/src/containers/job/JobManagerContainer.ts b/src/containers/job/JobManagerContainer.ts index f24f498a..c687aa6f 100644 --- a/src/containers/job/JobManagerContainer.ts +++ b/src/containers/job/JobManagerContainer.ts @@ -591,6 +591,12 @@ export class JobManagerContainer extends Container { privateKeyFile: await userConfigService.getDeployPrivateKeyPath() }); + await this.schedule(driveId, { + type: 'run_action', + title: 'Run action: on git_pull', + trigger: 'git_pull' + }); + return {}; } catch (err) { logger.error(err.stack ? err.stack : err.message); @@ -699,6 +705,12 @@ export class JobManagerContainer extends Container { } break; } + + await this.schedule(driveId, { + type: 'run_action', + title: 'Run action: on git_reset', + trigger: 'git_reset' + }); } catch (err) { logger.error(err.message); if (err.message.indexOf('Failed to retrieve list of SSH authentication methods') > -1) {