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

feat/gh-actions #506

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .github/workflows/DevelopServerDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
-v /home/wikigdrive/service_account.json:/service_account.json \
-v /home/wikigdrive/env.develop:/usr/src/app/.env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/podman/podman.sock:/var/run/podman/podman.sock \
-v "/var/www/dev.wikigdrive.com:/usr/src/app/dist/hugo" \
-e "GIT_SHA=${GITHUB_SHA}" \
-e "ZIPKIN_URL=https://dev.wikigdrive.com/zipkin" \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ProdServerDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
-v /home/wikigdrive/service_account.json:/service_account.json \
-v /home/wikigdrive/env.prod:/usr/src/app/.env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/podman/podman.sock:/var/run/podman/podman.sock \
-v "/var/www/wikigdrive.com:/usr/src/app/dist/hugo" \
-e "GIT_SHA=${GITHUB_SHA}" \
--publish 127.0.0.1:3000:3000 \
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/feat-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ jobs:
build:
needs: test
runs-on: ubuntu-latest

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
GH_TOKEN: ${{ github.token }}
BODY: ${{ github.event.head_commit.message }}
steps:
- uses: actions/checkout@v4
- name: Create pull request
id: open-pr
uses: repo-sync/pull-request@v2
with:
destination_branch: "master"
pr_title: "${BRANCH_NAME}"
pr_template: ".github/pull_request.md"
pr_draft: true
run: |
gh_pr_up() {
gh pr create --draft $* --body "${BODY}" || gh pr edit $* --body "${BODY}"
}
gh_pr_up --base master --title "${BRANCH_NAME}"
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jobs:
-v /home/wikigdrive/service_account.json:/service_account.json \
-v /home/wikigdrive/env.pr:/usr/src/app/.env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/podman/podman.sock:/var/run/podman/podman.sock \
-e "GIT_SHA=${{ github.sha }}" \
-v "/var/www/pr-${{ github.event.number }}.wikigdrive.com:/usr/src/app/website/.vitepress/dist" \
-e "ZIPKIN_URL=https://pr-${{ github.event.number }}.wikigdrive.com/zipkin" \
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VOLUME /data
WORKDIR /usr/src/app

RUN apt-get update
RUN apt-get install -yq bash git-lfs openssh-client curl unzip socat
RUN apt-get install -yq bash git-lfs openssh-client curl unzip socat podman-remote
RUN curl -fsSL https://deno.land/install.sh | DENO_INSTALL=/usr/local sh

COPY package.json package-lock.json ./
Expand All @@ -30,4 +30,8 @@ WORKDIR "/usr/src/app"
# Add the GIT_SSH_COMMAND to /etc/profile so that we can debug git issues from the command line
RUN echo 'export GIT_SSH_COMMAND="ssh -i \$(pwd | sed s/_transform.*//)/.private/id_rsa"' >> /etc/profile

# Git 2.47:
RUN apk upgrade git --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
RUN git config --global --add safe.directory /srv/wikigdrive/*

CMD [ "sh", "-c", "wikigdrive --workdir /data server 3000" ]
16 changes: 15 additions & 1 deletion apps/ui/src/components/DriveTools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</div>
</template>
<script>
import {UtilsMixin} from './UtilsMixin.ts';
import {disableElement, UtilsMixin} from './UtilsMixin.ts';
import {UiMixin} from './UiMixin.ts';
import ToolButton from './ToolButton.vue';

Expand Down Expand Up @@ -89,6 +89,20 @@ export default {
GIT_SHA() {
return this.drive.GIT_SHA;
}
},
methods: {
async transformAll(event) {
await disableElement(event, async () => {
await this.authenticatedClient.fetchApi(`/api/run_action/${this.driveId}/transform_all`, {
method: 'post',
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify({})
});

});
},
}
};
</script>
157 changes: 100 additions & 57 deletions apps/ui/src/components/JobsViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,88 @@
<div class="container mainbar__content-height">
<StatusToolBar :active-tab="activeTab" />

<div>
<div class="card-footer" v-if="active_jobs.length === 0">
<div class="btn-group">
<a class="btn btn-outline-primary me-2" v-if="selectedFile.id && selectedFile.id !== 'TO_FILL'" @click.prevent="$emit('sync', { $event, file: selectedFile })">Sync Single</a>
<a class="btn btn-outline-danger me-2" v-if="drive.name" @click.prevent="syncAll">Sync All</a>
<a class="btn btn-outline-secondary me-2" v-if="!isGDocsPreview && drive.name && selectedFile.id" @click.prevent="$emit('transform', $event, selectedFile)">Transform Single Markdown</a>
<a class="btn btn-outline-secondary me-2" v-if="!isGDocsPreview && drive.name" @click.prevent="transformAll">Transform All Markdown</a>
<a class="btn btn-outline-secondary me-2" v-if="!isGDocsPreview && drive.name" @click.prevent="renderPreview">Render Preview</a>
</div>
</div>
<div class="overflow-scroll d-flex flex-row mt-3">

<div class="card mt-3">
<div class="card-header">
Jobs
<div class="flex-column order-0 w-auto">
<div class="d-block" v-if="active_jobs.length === 0">
<div class="btn-group-vertical w-100">
<a class="btn btn-outline-primary me-2" v-if="selectedFile.id && selectedFile.id !== 'TO_FILL'" @click.prevent="$emit('sync', { $event, file: selectedFile })">Sync Single</a>
<a class="btn btn-outline-danger me-2" v-if="drive.name" @click.prevent="syncAll">Sync All</a>
</div>
</div>
<div class="card-body">
<div class="row py-1 align-items-center" v-if="last_job.dateStr">
<div class="col-8">
<span v-if="last_job.kind === 'full'" class="fw-bold">Last full sync </span>
<span v-else class="fw-bold">Last synced </span>
<span class="small text-muted">{{ last_job.dateStr }} </span>
<span v-if="last_job.durationStr" class="small text-muted">&nbsp;{{ last_job.durationStr }}</span>
</div>
<div v-if="last_transform.durationStr" class="col-8">
<span class="fw-bold">Last transform took</span>
<span class="small text-muted">&nbsp;{{ last_transform.durationStr }}</span>
<div class="d-block mt-3" v-if="!isGDocsPreview && drive.name">
<h6>Workflows <a href="#workflows"><i class="fa-solid fa-edit"></i></a></h6>
<div class="btn-group-vertical w-100">
<div v-for="(workflow_job, id) in workflow_jobs" :key="id">
<a v-if="!workflow_job.hide_in_menu" class="btn btn-outline-secondary me-2 w-100" @click.prevent="runAction($event, id)">
{{ workflow_job.name }}
</a>
</div>
</div>
</div>
</div>
<div class="flex-grow-1 flex-shrink-1 overflow-scroll border-left-0-not-first ms-3">
<div class="card">
<div class="card-header">
Jobs
</div>
<div class="card-body">
<div class="row py-1 align-items-center" v-if="last_job.dateStr">
<div class="col-8">
<span v-if="last_job.kind === 'full'" class="fw-bold">Last full sync </span>
<span v-else class="fw-bold">Last synced </span>
<span class="small text-muted">{{ last_job.dateStr }} </span>
<span v-if="last_job.durationStr" class="small text-muted">&nbsp;{{ last_job.durationStr }}</span>
</div>
<div v-if="last_transform.durationStr" class="col-8">
<span class="fw-bold">Last transform took</span>
<span class="small text-muted">&nbsp;{{ last_transform.durationStr }}</span>
</div>
</div>

<table class="table table-bordered jobs-list mt-3">
<thead>
<tr>
<th>Job</th>
<th>Started</th>
<th>Finished</th>
</tr>
</thead>
<table class="table table-bordered jobs-list mt-3">
<thead>
<tr>
<th>Job</th>
<th>Started</th>
<th>Finished</th>
</tr>
</thead>

<tbody v-if="active_jobs_reverse.length > 0">
<tr v-for="(job, idx) of active_jobs_reverse" :key="idx" class="jobs-list__item" :class="{ active: 'running' === job.state }">
<td>{{ job.title }}</td>
<td>{{ job.startedStr || job.state }}</td>
<td>
<span v-if="job.progress && job.progress.total > job.progress.completed">&nbsp;{{ job.progress.completed }} / {{ job.progress.total }}</span>
<a v-if="job.id && job.started" class="btn float-end" :href="'#drive_logs:job-' + job.id" @click.prevent="showLogs(job)">Logs</a>
</td>
</tr>
</tbody>
<tbody v-if="active_jobs_reverse.length > 0">
<tr v-for="(job, idx) of active_jobs_reverse" :key="idx" class="jobs-list__item" :class="{ active: 'running' === job.state }">
<td>{{ job.title }}</td>
<td>{{ job.startedStr || job.state }}</td>
<td>
<span v-if="job.progress && job.progress.total > job.progress.completed">&nbsp;{{ job.progress.completed }} / {{ job.progress.total }}</span>
<a v-if="job.id && job.started" class="btn float-end" :href="'#drive_logs:job-' + job.id" @click.prevent="showLogs(job)">Logs</a>
</td>
</tr>
</tbody>

<tbody>
<tr v-for="(job, idx) of archive" :key="idx" class="jobs-list__item" :class="{ active: 'running' === job.state, 'text-danger': 'failed' === job.state, 'text-warning': job.progress && job.progress.warnings > 0 }">
<td>{{ job.title }}</td>
<td>{{ job.startedStr }}</td>
<td>
{{ job.finishedStr }}
({{ job.durationStr }})
<a class="btn float-end" :href="'#drive_logs:job-' + job.id" @click.prevent="showLogs(job)">Logs</a>
</td>
</tr>
</tbody>
</table>
<tbody>
<tr v-for="(job, idx) of archive" :key="idx" class="jobs-list__item" :class="{ active: 'running' === job.state, 'text-danger': 'failed' === job.state, 'text-warning': job.progress && job.progress.warnings > 0 }">
<td>{{ job.title }}</td>
<td>{{ job.startedStr }}</td>
<td>
{{ job.finishedStr }}
({{ job.durationStr }})
<a class="btn float-end" :href="'#drive_logs:job-' + job.id" @click.prevent="showLogs(job)">Logs</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

</div>
</div>
</template>
<script>
import {UtilsMixin} from './UtilsMixin.ts';
import {disableElement, UtilsMixin} from './UtilsMixin.ts';
import {UiMixin} from './UiMixin.ts';
import StatusToolBar from './StatusToolBar.vue';
import yaml from 'js-yaml';

export default {
name: 'JobsViewer',
Expand All @@ -83,7 +94,15 @@
type: String
}
},
data() {
return {
workflow_jobs: []
};
},
components: {StatusToolBar},
created() {
this.fetchConfig();
},
computed: {
active_jobs_reverse() {
return [].concat(this.active_jobs)
Expand Down Expand Up @@ -114,7 +133,31 @@
methods: {
showLogs(job) {
this.$router.push(`/drive/${this.driveId}#drive_logs:job-${job.id}`);
}
},
async fetchConfig() {
const response = await this.authenticatedClient.fetchApi(`/api/config/${this.driveId}`);
const json = await response.json();
if (json.config?.actions_yaml) {
const actions_yaml = json.config?.actions_yaml;
this.workflow_jobs = {};
yaml.loadAll(actions_yaml, (workflow) => {

Check warning on line 143 in apps/ui/src/components/JobsViewer.vue

View workflow job for this annotation

GitHub Actions / test

Caution: `yaml` also has a named export `loadAll`. Check if you meant to write `import {loadAll} from 'js-yaml'` instead

Check warning on line 143 in apps/ui/src/components/JobsViewer.vue

View workflow job for this annotation

GitHub Actions / test

Caution: `yaml` also has a named export `loadAll`. Check if you meant to write `import {loadAll} from 'js-yaml'` instead

Check warning on line 143 in apps/ui/src/components/JobsViewer.vue

View workflow job for this annotation

GitHub Actions / test

Caution: `yaml` also has a named export `loadAll`. Check if you meant to write `import {loadAll} from 'js-yaml'` instead
this.workflow_jobs = workflow.jobs;
});
}
},
async runAction(event, id) {
await disableElement(event, async () => {
await this.authenticatedClient.fetchApi(`/api/run_action/${this.driveId}/${id}`, {
method: 'post',
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify({
selectedFileId: this.selectedFile.id
})
});
});
},
}
};
</script>
21 changes: 0 additions & 21 deletions apps/ui/src/components/UtilsMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,6 @@ export const UtilsMixin = {
});
});
},
async renderPreview(event) {
await disableElement(event, async () => {
await this.authenticatedClient.fetchApi(`/api/run_action/${this.driveId}/transform`, {
method: 'post'
});
});
},
async transformAll(event) {
await disableElement(event, async () => {
await this.authenticatedClient.fetchApi(`/api/transform/${this.driveId}`, {
method: 'post'
});
});
},
async uploadGdrive(event) {
await disableElement(event, async () => {
const response = await this.authenticatedClient.fetchApi('/api/gdrive/' + this.driveId + '/upload', { method: 'get' });
Expand All @@ -235,13 +221,6 @@ export const UtilsMixin = {
}
});
},
async transformSingle(event, selectedFile) {
await disableElement(event, async () => {
await this.authenticatedClient.fetchApi(`/api/transform/${this.driveId}/${selectedFile.id}`, {
method: 'post'
});
});
},
downloadOdt(fileId) {
const odtPath = `/api/drive/${this.driveId}/file/${fileId}.odt`;
window.open(odtPath, '_blank');
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/components/WorkflowsEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="card-body">
<form>
<div class="form-group">
<label>Config.toml for preview</label>
<label>Workflows</label>
<CodeEditor v-model="user_config.actions_yaml" lang="yaml" />
</div>
</form>
Expand Down
12 changes: 6 additions & 6 deletions apps/ui/src/modals/ToastsMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export const ToastsMixin = {
await this.$root.changeDrive(this.drive.id);
window.location.reload();
break;
case 'transform:scheduled':
this.$removeToastMatching(item => item.type.startsWith('transform:'));
case 'action:scheduled':
this.$removeToastMatching(item => item.type.startsWith('action:'));
break;
case 'transform:failed':
this.$removeToastMatching(item => item.type.startsWith('transform:'));
case 'action:failed':
this.$removeToastMatching(item => item.type.startsWith('action:'));
break;
case 'transform:done':
this.$removeToastMatching(item => item.type.startsWith('transform:'));
case 'action:done':
this.$removeToastMatching(item => item.type.startsWith('action:'));
break;
case 'sync:done':
}
Expand Down
4 changes: 2 additions & 2 deletions apps/ui/src/pages/FolderView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</div>
</div>

<JobsViewer v-if="activeTab === 'sync'" :selected-file="selectedFile" :activeTab="activeTab" @sync="syncSingle($event.$event, $event.file)" @transform="transformSingle" @showLogs="showLogs" />
<ChangesViewer v-if="activeTab === 'changes'" :selected-file="selectedFile" :activeTab="activeTab" @sync="syncSingle($event.$event, $event.file)" @transform="transformSingle" @showLogs="showLogs" />
<JobsViewer v-if="activeTab === 'sync'" :selected-file="selectedFile" :activeTab="activeTab" @sync="syncSingle($event.$event, $event.file)" @showLogs="showLogs" />
<ChangesViewer v-if="activeTab === 'changes'" :selected-file="selectedFile" :activeTab="activeTab" @sync="syncSingle($event.$event, $event.file)" @showLogs="showLogs" />
<GitLog v-if="activeTab === 'git_log'" :folderPath="folderPath" :selectedFile="selectedFile" :active-tab="activeTab" />

<DriveTools v-if="activeTab === 'drive_tools'" :folderPath="folderPath" :selectedFile="selectedFile" :selected-folder="selectedFolder" :active-tab="activeTab" />
Expand Down
13 changes: 7 additions & 6 deletions apps/wgd-action-runner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:lts-buster
FROM node:22-bookworm-slim
MAINTAINER Grzegorz Godlewski <[email protected]>

ADD site/ /site
Expand All @@ -8,18 +8,19 @@ ENV THEME_ID=""
ENV THEME_URL=""
ENV NO_COLOR="true"

VOLUME ["/site/content"]
VOLUME ["/site/public"]

RUN apt-get update
RUN apt-get install -y git nodejs curl python3 python3-pip
RUN pip3 install s3cmd
RUN apt-get install -y git nodejs curl python3 python3-pip s3cmd yq
RUN npm i -g postcss postcss-cli hugo-extended

RUN mkdir -p /gh_actions

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_*

WORKDIR /site
ENTRYPOINT /bin/bash
Loading
Loading