chore(ci): add .gitfoss.ci@@ -0,0 +1,57 @@
+stages:
+ - name: build
+ image: alpine:3.18
+ workdir: ./.workdir/:/home/node/
+ env:
+ FOO: "$HOME"
+ shell: sh
+ steps:
+ - name: build:gitfoss_web
+ commands:
+ - git clone https://gitfoss.dev/ethicdevs/gitfoss.git || true
+ - cd gitfoss/
+ - git fetch
+ - git checkout master
+ - yarn
+ - yarn build
+ -
+ cached:
+ - /home/node/build/gitfoss/dist/
+ - /home/node/build/gitfoss/public/
+ - /home/node/build/gitfoss/.gitstamp
+ - name: build:gitfoss_web_docker
+ env:
+ IMAGE: "gitfoss_web:$(git rev-parse --short HEAD)"
+ HOST: "0.0.0.0"
+ PORT: 3000
+ commands:
+ - git clone https://gitfoss.dev/ethicdevs/gitfoss.git || true
+ - cd gitfoss/
+ - git fetch
+ - git checkout master
+ - docker build --build-arg HOST=${HOST} --build-arg PORT=${PORT} -f Dockerfile -t ${IMAGE} .
+ - docker save -o ./${IMAGE}.tar docker.io/library/${IMAGE}
+ cached:
+ - /home/node/build/gitfoss/${IMAGE}.tar
+ - name: build:gitfoss_ci
+ commands:
+ - git clone https://gitfoss.dev/ethicdevs/gitfoss.git || true
+ - cd gitfoss/
+ - git fetch
+ - git checkout master
+ - cd ./packages/gitfoss-ci/
+ - shards install
+ - shards build
+ cached:
+ - /home/node/build/gitfoss/packages/gitfoss-ci/bin/gitfoss-ci
+ - name: build:gitfoss_ci:runner
+ commands:
+ - git clone https://gitfoss.dev/ethicdevs/gitfoss.git || true
+ - cd gitfoss/
+ - git fetch
+ - git checkout master
+ - cd ./packages/gitfoss-ci-runner/
+ - shards install
+ - shards build
+ cached:
+ - /home/node/build/gitfoss/packages/gitfoss-ci-runner/bin/gitfoss-ci-runner
@@ -42,6 +42,7 @@ import {
makeRequestHandler,
sessionSetupPreHandler,
} from "./utils/server";
+import { makeRepositoryService } from "./services/repository";
let server: null | AppServer<AppRouteParams> = null;
@@ -272,9 +273,15 @@ async function main(): Promise<AppServer> {
// register the crypto plugin
s.register(cryptoPlugin).after(() => {
+ const repoService = makeRepositoryService({
+ request: {
+ prisma,
+ } as any,
+ });
// make a git service instance
const gitService = makeGitServerService({
cryptoService: s.cryptoService,
+ repoService: repoService,
request: {
prisma,
} as any,
@@ -23,17 +23,16 @@ const makeOnPushEvent: ServiceMethodFactory<
GitServerServiceDeps,
[GitServer.Event],
void
-> = ({ request }) => {
+> = ({ request, repoService }) => {
const env = getEnv();
- return ({ type, data, message }) => {
+ return ({ data, message }) => {
if (data.packType === GitServer.PackType.RECEIVE) {
// client has done something like "git push" it is uploading
// server is receiving
console.log("receive-pack");
message.write("\n");
- console.log("git.onPushEvent:", type, data, message);
- console.log("git.onPushEvent: data.payload.metas:", data.payload?.metas);
+ // console.log("git.onPushEvent:", type, data, message);
// git push:
// on data.requestType === 'git-receive-pack'
@@ -63,6 +62,26 @@ const makeOnPushEvent: ServiceMethodFactory<
})
.then(async (repo) => {
if (repo == null) return Promise.resolve(null);
+
+ try {
+ const ciManifest = await repoService!.getRepositoryFileContent(
+ repo,
+ ".gitfoss.ci",
+ data.payload!.refName,
+ );
+ console.log(
+ "ci manifest:",
+ `${orgSlug}/${repoSlug}` + "/.gitfoss.ci:\n",
+ ciManifest,
+ );
+ } catch (err) {
+ console.log(
+ "could not get ci manifest:",
+ `${orgSlug}/${repoSlug}`,
+ "/.gitfoss.ci",
+ );
+ }
+
const updatedRepo = await request.prisma.repository.update({
where: {
id: repo.id,
@@ -81,11 +100,6 @@ const makeOnPushEvent: ServiceMethodFactory<
? `${repoUrlPrefix}/${repoUrlSuffix}`
: `${repoUrlPrefix}:${Env.PORT}/${repoUrlSuffix}`;
- // Finally, accept the payload from client
- message.accept();
-
- // test2
-
if (data.payload != null) {
message.write(toAscii(`Hey ${data.username}, welcome back 🖖.\n\n`));
message.write(toAscii(`📖 See the details of your push at:\n`));
@@ -122,17 +136,17 @@ const makeOnPushEvent: ServiceMethodFactory<
message.write("\n");
} else if (data.packType === GitServer.PackType.UPLOAD) {
- // Finally, accept the payload from client
- message.accept();
-
// client has done something like "git clone" or "git fetch" or "git pull",
// it is receiving, server is uploading
console.log("upload-pack");
// ⬇️ disabled because it seem to cause issues on git pull. ⬇️
- message.write(toAscii(`🖖 Welcome at GitFOSS ${data.username}!\n`));
+ // message.write(toAscii(`🖖 Welcome at GitFOSS ${data.username}!\n`));
console.log("upload-pack:", data, message);
}
+
+ // Finally, accept the payload from client
+ message.accept();
};
};
@@ -5,6 +5,7 @@ import type { ServiceApiContract } from "@ethicdevs/react-monolith";
import type { FastifyRequest } from "fastify";
// app
import type { CryptoServiceAPI } from "../crypto/types";
+import type { RepositoryServiceAPI } from "../repository/types";
export interface GitServerServiceAPI extends ServiceApiContract {
authorizationResolver(
@@ -20,5 +21,6 @@ export interface GitServerServiceAPI extends ServiceApiContract {
export interface GitServerServiceDeps {
cryptoService: CryptoServiceAPI;
+ repoService?: RepositoryServiceAPI;
request: FastifyRequest;
}