From 3dae6aec05028b1f30dac6c595afae9bc18709af Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sat, 24 May 2025 16:27:31 +0200 Subject: [PATCH 01/12] =?UTF-8?q?=F0=9F=9A=A7=20wip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/content/docs/changelog/v1.10.mdx | 43 ++++++++++++++++++++++++++++ src/content/docs/index.mdx | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/content/docs/changelog/v1.10.mdx diff --git a/package.json b/package.json index 000d176..9f73e5c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "type": "module", "version": "0.0.1", "scripts": { - "dev": "astro dev --port 3000 --host", + "dev": "astro dev --port ${PORT:-3000} --host", "start": "astro dev", "build": "astro check && astro build", "preview": "astro preview", diff --git a/src/content/docs/changelog/v1.10.mdx b/src/content/docs/changelog/v1.10.mdx new file mode 100644 index 0000000..de767ab --- /dev/null +++ b/src/content/docs/changelog/v1.10.mdx @@ -0,0 +1,43 @@ +--- +title: ZaneOps v1.10 +description: 'Sh...🤫 ells !' +--- + +import {Aside} from '@astrojs/starlight/components'; + +21 May 2025 by [**Fred KISSIE**](https://github.com/Fredkiss3) + +Today we release zaneOps v1.10 introducing shells for everyone + + +**To install :** + +1. via the UI : + clone environment modal + clone environment modal + + project environments page + project environments page + + +3. via the shell : + ```shell + # assuming you are at /var/www/zaneops + curl https://cdn.zaneops.dev/makefile > Makefile + make setup + make deploy + ``` + +### Shells to deployments + +> todo + +### Shell to the server + +> todo + + +### Other changes + +- ZaneOps docker image is lighter and with a smaller number of layers ! Downloading new versions of ZaneOps should be faster in the next releases. +- We introduced a new anonymous telemetry to allows us to better see the real usage of ZaneOps in production, [how to configure ?](#) \ No newline at end of file diff --git a/src/content/docs/index.mdx b/src/content/docs/index.mdx index 3ac298f..ad9796d 100644 --- a/src/content/docs/index.mdx +++ b/src/content/docs/index.mdx @@ -4,7 +4,7 @@ description: ZaneOps is a self-hosted, open source platform as a service for hos template: splash banner: content: | - In v1.9, ZaneOps replaces Vercel (well... kinda) + Shells for everyone ! (v1.10) hero: tagline: your all-in-one self-hosted platform for deploying apps with ✨ zen ✨. image: From a11944909f3bdcaad0cb61e45cb2e1170a6fe5ea Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sat, 24 May 2025 19:15:27 +0200 Subject: [PATCH 02/12] =?UTF-8?q?=F0=9F=9A=A7=20wip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 81 +++--------- .github/workflows/close-pr-env.yaml | 30 +++++ package.json | 4 + pnpm-lock.yaml | 25 +++- scripts/close-pr.ts | 71 +++++++++++ scripts/common.ts | 126 +++++++++++++++++++ scripts/deploy-pr.ts | 102 +++++++++++++++ 7 files changed, 371 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/close-pr-env.yaml create mode 100644 scripts/close-pr.ts create mode 100644 scripts/common.ts create mode 100644 scripts/deploy-pr.ts diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index 7440784..e6929f3 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -4,79 +4,26 @@ on: workflow_dispatch: jobs: - build-push-docs: - name: Build and Push Zane docs dev images - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - attestations: write - id-token: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Cache pnpm dependencies - uses: actions/cache@v3 - with: - path: ~/.pnpm-store - key: ${{ runner.OS }}-pnpm-cache-${{ hashFiles('pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.OS }}-pnpm-cache- - - name: Build docs with node - run: | - npm install -g pnpm@8 - pnpm install --frozen-lockfile - FORCE_COLOR=true pnpm run build - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.CONTAINER_REGISTRY_PAT }} - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - file: Dockerfile - push: true - platforms: linux/amd64,linux/arm64 - tags: ghcr.io/zane-ops/docs:pr-${{ github.event.pull_request.number }},ghcr.io/zane-ops/docs:${{ github.sha }} - cache-from: | - type=registry,ref=ghcr.io/zane-ops/docs:pr-${{ github.event.pull_request.number }} - type=registry,ref=ghcr.io/zane-ops/docs:latest - cache-to: type=inline deploy: runs-on: ubuntu-latest name: Deploy - needs: build-push-docs steps: - name: Checkout uses: actions/checkout@v4 - - - name: Get commit message - id: get-commit - run: echo "commit_message=$(git log -1 --pretty=format:%s)" >> $GITHUB_OUTPUT - - - name: Bypass Cloudflare for GitHub Action - uses: xiaotianxt/bypass-cloudflare-for-github-action@v1.1.1 + + - uses: oven-sh/setup-bun@v2 with: - cf_zone_id: ${{ secrets.CF_ZONE_ID }} - cf_api_token: ${{ secrets.CF_API_TOKEN }} - - name: Deploy to ZaneOps + bun-version: latest + + - name: Install packages and Deploy to zaneops + shell: bash run: | - curl -f -o /dev/null --fail \ - -H "CF-Access-Client-Id: ${{ secrets.CF_CLIENT_ID }}" \ - -H "CF-Access-Client-Secret: ${{ secrets.CF_CLIENT_SECRET }}" \ - -X PUT ${{ secrets.STAGING_DEPLOY_WEBHOOK_URL }} \ - --data '{ - "commit_message": "${{ steps.get-commit.outputs.commit_message }}", - "new_image": "ghcr.io/zane-ops/docs:${{ github.sha }}" - }' + bun install cookie-es zod@3 + bun run scripts/deploy-pr.ts + env: + CF_CLIENT_ID: ${{ secrets.CF_ZONE_ID }} + CF_CLIENT_SECRET: ${{ secrets.CF_API_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + ZANE_USERNAME: ${{ secrets.ZANE_USERNAME }} + ZANE_PASSWORD: ${{ secrets.ZANE_PASSWORD }} diff --git a/.github/workflows/close-pr-env.yaml b/.github/workflows/close-pr-env.yaml new file mode 100644 index 0000000..e660abc --- /dev/null +++ b/.github/workflows/close-pr-env.yaml @@ -0,0 +1,30 @@ +name: Close PR environment (DEV) +on: + pull_request: + types: [closed] + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + name: Deploy + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Close PR + shell: bash + run: | + bun install cookie-es zod@3 + bun run scripts/close-pr.ts + env: + CF_CLIENT_ID: ${{ secrets.CF_ZONE_ID }} + CF_CLIENT_SECRET: ${{ secrets.CF_API_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + ZANE_USERNAME: ${{ secrets.ZANE_USERNAME }} + ZANE_PASSWORD: ${{ secrets.ZANE_PASSWORD }} + diff --git a/package.json b/package.json index 9f73e5c..efb7344 100644 --- a/package.json +++ b/package.json @@ -25,5 +25,9 @@ "sharp": "^0.32.6", "tailwindcss": "^3.4.6", "typescript": "^5.5.3" + }, + "devDependencies": { + "@types/bun": "^1.2.14", + "cookie-es": "^2.0.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fbccd23..c5c0133 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -51,6 +51,14 @@ dependencies: specifier: ^5.5.3 version: 5.6.3 +devDependencies: + '@types/bun': + specifier: ^1.2.14 + version: 1.2.14 + cookie-es: + specifier: ^2.0.0 + version: 2.0.0 + packages: /@alloc/quick-lru@5.2.0: @@ -1478,6 +1486,12 @@ packages: '@babel/types': 7.26.0 dev: false + /@types/bun@1.2.14: + resolution: {integrity: sha512-VsFZKs8oKHzI7zwvECiAJ5oSorWndIWEVhfbYqZd4HI/45kzW7PN2Rr5biAzvGvRuNmYLSANY+H59ubHq8xw7Q==} + dependencies: + bun-types: 1.2.14 + dev: true + /@types/cookie@0.6.0: resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} dev: false @@ -1526,7 +1540,6 @@ packages: /@types/node@17.0.45: resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} - dev: false /@types/prop-types@15.7.13: resolution: {integrity: sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA==} @@ -1988,6 +2001,12 @@ packages: ieee754: 1.2.1 dev: false + /bun-types@1.2.14: + resolution: {integrity: sha512-Kuh4Ub28ucMRWeiUUWMHsT9Wcbr4H3kLIO72RZZElSDxSu7vpetRvxIUDUaW6QtaIeixIpm7OXtNnZPf82EzwA==} + dependencies: + '@types/node': 17.0.45 + dev: true + /camelcase-css@2.0.1: resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==} engines: {node: '>= 6'} @@ -2133,6 +2152,10 @@ packages: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} dev: false + /cookie-es@2.0.0: + resolution: {integrity: sha512-RAj4E421UYRgqokKUmotqAwuplYw15qtdXfY+hGzgCJ/MBjCVZcSoHK/kH9kocfjRjcDME7IiDWR/1WX1TM2Pg==} + dev: true + /cookie@0.7.2: resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} engines: {node: '>= 0.6'} diff --git a/scripts/close-pr.ts b/scripts/close-pr.ts new file mode 100644 index 0000000..26fc158 --- /dev/null +++ b/scripts/close-pr.ts @@ -0,0 +1,71 @@ +import { + DASHBOARD_URL, + ENV_NAME, + PROJECT_SLUG, + PR_NUMBER, + authenticate, + colors, + extraHeaders, + parseResponseBody +} from "./common"; +const { requestCookie, csrfToken } = await authenticate(); + +/*****************************/ +/* CLOSING PR ENV */ +/*****************************/ + +console.log( + `Creating new environment ${colors.blue( + `pr-${PR_NUMBER}` + )} in the project ${colors.blue(PROJECT_SLUG)}...` +); +const getEnvRequest = await fetch( + `${DASHBOARD_URL}/api/projects/${PROJECT_SLUG}/environment-details/${ENV_NAME}/`, + { + method: "GET", + headers: { + "x-csrftoken": csrfToken, + cookie: requestCookie, + ...extraHeaders + } + } +); +if (![200, 404].includes(getEnvRequest.status)) { + console.error(colors.red("❌ Failed to GET the environment for the PR ❌")); + console.error( + `Received status code from zaneops API : ${colors.red(getEnvRequest.status)}` + ); + + console.error("Received response from zaneops API : "); + console.dir(await parseResponseBody(getEnvRequest), { depth: null }); + process.exit(1); +} + +if (getEnvRequest.status === 200) { + const deleteEnvRequest = await fetch( + `${DASHBOARD_URL}/api/projects/${PROJECT_SLUG}/environment-details/${ENV_NAME}/`, + { + method: "DELETE", + headers: { + "x-csrftoken": csrfToken, + cookie: requestCookie, + ...extraHeaders + } + } + ); + + if (deleteEnvRequest.status !== 204) { + console.error( + colors.red("❌ Failed to archive the environment for the PR ❌") + ); + console.error( + `Received status code from zaneops API : ${colors.red(getEnvRequest.status)}` + ); + + console.error("Received response from zaneops API : "); + console.dir(await parseResponseBody(getEnvRequest), { depth: null }); + process.exit(1); + } +} + +console.log(`Succesfully archived environment ${colors.blue(ENV_NAME)} ✅`); diff --git a/scripts/common.ts b/scripts/common.ts new file mode 100644 index 0000000..8c71b33 --- /dev/null +++ b/scripts/common.ts @@ -0,0 +1,126 @@ +import * as cookie from "cookie-es"; +import { z } from "zod"; + +const envVariables = z.object({ + ZANE_USERNAME: z.string(), + ZANE_PASSWORD: z.string(), + CF_CLIENT_ID: z.string(), + CF_CLIENT_SECRET: z.string(), + PR_NUMBER: z.coerce.number() +}); +export const PROJECT_SLUG = "zane-docs"; +export const DASHBOARD_URL = "https://lab.fkiss.me"; +export const SERVICE_SLUG = "zn-docs"; +export type EnvResponse = { + name: string; + services: Array<{ + slug: string; + urls: Array<{ domain: string }>; + }>; +}; + +const Colors = { + GREEN: "\x1b[92m", + BLUE: "\x1b[94m", + ORANGE: "\x1b[38;5;208m", + RED: "\x1b[91m", + GREY: "\x1b[90m", + ENDC: "\x1b[0m" +} as const; + +export const colors = { + green: (input: any) => `${Colors.GREEN}${input}${Colors.ENDC}`, + blue: (input: any) => `${Colors.BLUE}${input}${Colors.ENDC}`, + orange: (input: any) => `${Colors.ORANGE}${input}${Colors.ENDC}`, + red: (input: any) => `${Colors.RED}${input}${Colors.ENDC}`, + grey: (input: any) => `${Colors.GREY}${input}${Colors.ENDC}` +} as const; + +export async function parseResponseBody(response: Response) { + return response.headers.get("content-type") === "application/json" + ? await response.json() + : await response.text(); +} + +export const { + ZANE_USERNAME: username, + ZANE_PASSWORD: password, + CF_CLIENT_ID, + CF_CLIENT_SECRET, + PR_NUMBER +} = envVariables.parse(process.env); +export const ENV_NAME = `pr-${PR_NUMBER}`; + +export const extraHeaders = { + "CF-Access-Client-Id": CF_CLIENT_ID, + "CF-Access-Client-Secret": CF_CLIENT_SECRET +}; + +export async function authenticate() { + /*****************************/ + /* CSRF TOKEN */ + /*****************************/ + console.log( + `Getting the CSRF token on ZaneOps API at ${colors.blue(DASHBOARD_URL)}...` + ); + const csrfResponse = await fetch(`${DASHBOARD_URL}/api/csrf`, { + headers: extraHeaders + }); + if (csrfResponse.status !== 200) { + console.error( + colors.red("❌ Failed to get CSRF token from ZaneOps API ❌") + ); + console.error( + `Received status code from zaneops API : ${colors.red(csrfResponse.status)}` + ); + + console.error("Received response from zaneops API : "); + console.dir(await parseResponseBody(csrfResponse), { depth: null }); + process.exit(1); + } else { + console.log(`Got the CSRF token successfully ✅`); + } + const csrfTokenStr = cookie + .splitSetCookieString(csrfResponse.headers.get("set-cookie") ?? "") + .filter((cookieStr) => cookieStr.startsWith("csrftoken"))[0]; + const csrfToken = cookie.parseSetCookie(csrfTokenStr).value; + + /*****************************/ + /* AUTHENTICATION */ + /*****************************/ + console.log(`Authenticating to ZaneOps API...`); + const authResponse = await fetch(`${DASHBOARD_URL}/api/auth/login`, { + method: "POST", + headers: { + "x-csrftoken": csrfToken, + cookie: `csrftoken=${csrfToken}`, + "content-type": "application/json", + ...extraHeaders + }, + body: JSON.stringify({ username, password }) + }); + if (authResponse.status !== 201) { + console.error(colors.red("❌ Failed to authenticate to ZaneOps API ❌")); + console.error( + `Received status code from zaneops API : ${colors.red(authResponse.status)}` + ); + + console.error("Received response from zaneops API : "); + console.dir(await parseResponseBody(authResponse), { depth: null }); + process.exit(1); + } else { + console.log(`Successfully Authenticated to ZaneOps API ✅`); + } + + const sessionIdCookieStr = cookie + .splitSetCookieString(authResponse.headers.get("set-cookie") ?? "") + .filter((cookieStr) => cookieStr.startsWith("sessionid"))[0]; + + const sessionId = cookie.parseSetCookie(sessionIdCookieStr).value; + const requestCookie = [ + cookie.serialize("sessionid", sessionId), + cookie.serialize("csrftoken", csrfToken), + "" + ].join(";"); + return { requestCookie, csrfToken }; +} diff --git a/scripts/deploy-pr.ts b/scripts/deploy-pr.ts new file mode 100644 index 0000000..dfb01e7 --- /dev/null +++ b/scripts/deploy-pr.ts @@ -0,0 +1,102 @@ +import { + DASHBOARD_URL, + ENV_NAME, + type EnvResponse, + PROJECT_SLUG, + PR_NUMBER, + SERVICE_SLUG, + authenticate, + colors, + extraHeaders, + parseResponseBody +} from "./common"; +const { requestCookie, csrfToken } = await authenticate(); + +/*****************************/ +/* CLONING PROD ENV */ +/*****************************/ +console.log( + `Creating new environment ${colors.blue( + `pr-${PR_NUMBER}` + )} in the project ${colors.blue(PROJECT_SLUG)}...` +); +const getEnvRequest = await fetch( + `${DASHBOARD_URL}/api/projects/${PROJECT_SLUG}/environment-details/${ENV_NAME}/`, + { + method: "GET", + headers: { + "x-csrftoken": csrfToken, + cookie: requestCookie, + ...extraHeaders + } + } +); +if (![200, 404].includes(getEnvRequest.status)) { + console.error(colors.red("❌ Failed to GET the environment for the PR ❌")); + console.error( + `Received status code from zaneops API : ${colors.red(getEnvRequest.status)}` + ); + + console.error("Received response from zaneops API : "); + console.dir(await parseResponseBody(getEnvRequest), { depth: null }); + process.exit(1); +} + +let envResponse: EnvResponse; + +if (getEnvRequest.status === 200) { + envResponse = await getEnvRequest.json(); +} else { + const cloneEnvRequest = await fetch( + `${DASHBOARD_URL}/api/projects/${PROJECT_SLUG}/clone-environment/production/`, + { + method: "POST", + headers: { + "x-csrftoken": csrfToken, + cookie: requestCookie, + "content-type": "application/json", + ...extraHeaders + }, + body: JSON.stringify({ + name: `pr-${PR_NUMBER}`, + deploy_services: true + }) + } + ); + + if (![201, 409].includes(cloneEnvRequest.status)) { + console.error( + colors.red("❌ Failed to clone the production environment ❌") + ); + console.error( + `Received status code from zaneops API : ${colors.red(cloneEnvRequest.status)}` + ); + + console.error("Received response from zaneops API : "); + console.dir(await parseResponseBody(cloneEnvRequest), { depth: null }); + process.exit(1); + } else { + console.log(`Successfully created environment ${colors.blue(ENV_NAME)} ✅`); + envResponse = await cloneEnvRequest.json(); + } +} + +console.log(`Environment available in ${colors.blue(ENV_NAME)}`); + +const docsService = envResponse.services.find( + (srv) => srv.slug === SERVICE_SLUG +); +if (!docsService) { + console.error( + `The cloned environment doesn't have the service "${SERVICE_SLUG}"` + ); + process.exit(1); +} + +const domain = docsService.urls[0].domain; +const file = Bun.file("./service-url"); +const writer = file.writer(); +writer.write(docsService.urls[0].domain); +writer.flush(); +writer.end(); +console.log(`Service deployed to ${colors.green(domain)} !`); From bb98c0ec7de7592410d281bd1a07337fe9a48def Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 03:34:18 +0200 Subject: [PATCH 03/12] =?UTF-8?q?=F0=9F=9A=A7=20wip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 1 + scripts/close-pr.ts | 4 +- scripts/common.ts | 11 +- scripts/deploy-pr.ts | 102 ++++++++++++++++++- 4 files changed, 105 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index e6929f3..78b0298 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -24,6 +24,7 @@ jobs: CF_CLIENT_ID: ${{ secrets.CF_ZONE_ID }} CF_CLIENT_SECRET: ${{ secrets.CF_API_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} + PR_BRANCH_NAME: ${{ github.head_ref }} ZANE_USERNAME: ${{ secrets.ZANE_USERNAME }} ZANE_PASSWORD: ${{ secrets.ZANE_PASSWORD }} diff --git a/scripts/close-pr.ts b/scripts/close-pr.ts index 26fc158..60d8ab6 100644 --- a/scripts/close-pr.ts +++ b/scripts/close-pr.ts @@ -2,9 +2,9 @@ import { DASHBOARD_URL, ENV_NAME, PROJECT_SLUG, - PR_NUMBER, authenticate, colors, + env, extraHeaders, parseResponseBody } from "./common"; @@ -16,7 +16,7 @@ const { requestCookie, csrfToken } = await authenticate(); console.log( `Creating new environment ${colors.blue( - `pr-${PR_NUMBER}` + `pr-${env.PR_NUMBER}` )} in the project ${colors.blue(PROJECT_SLUG)}...` ); const getEnvRequest = await fetch( diff --git a/scripts/common.ts b/scripts/common.ts index 8c71b33..8ea1c5a 100644 --- a/scripts/common.ts +++ b/scripts/common.ts @@ -6,6 +6,7 @@ const envVariables = z.object({ ZANE_PASSWORD: z.string(), CF_CLIENT_ID: z.string(), CF_CLIENT_SECRET: z.string(), + PR_BRANCH_NAME: z.string(), PR_NUMBER: z.coerce.number() }); export const PROJECT_SLUG = "zane-docs"; @@ -45,15 +46,13 @@ export async function parseResponseBody(response: Response) { export const { ZANE_USERNAME: username, ZANE_PASSWORD: password, - CF_CLIENT_ID, - CF_CLIENT_SECRET, - PR_NUMBER + ...env } = envVariables.parse(process.env); -export const ENV_NAME = `pr-${PR_NUMBER}`; +export const ENV_NAME = `pr-${env.PR_NUMBER}`; export const extraHeaders = { - "CF-Access-Client-Id": CF_CLIENT_ID, - "CF-Access-Client-Secret": CF_CLIENT_SECRET + "CF-Access-Client-Id": env.CF_CLIENT_ID, + "CF-Access-Client-Secret": env.CF_CLIENT_SECRET }; export async function authenticate() { diff --git a/scripts/deploy-pr.ts b/scripts/deploy-pr.ts index dfb01e7..1d7db8c 100644 --- a/scripts/deploy-pr.ts +++ b/scripts/deploy-pr.ts @@ -3,10 +3,10 @@ import { ENV_NAME, type EnvResponse, PROJECT_SLUG, - PR_NUMBER, SERVICE_SLUG, authenticate, colors, + env, extraHeaders, parseResponseBody } from "./common"; @@ -17,7 +17,7 @@ const { requestCookie, csrfToken } = await authenticate(); /*****************************/ console.log( `Creating new environment ${colors.blue( - `pr-${PR_NUMBER}` + `pr-${env.PR_NUMBER}` )} in the project ${colors.blue(PROJECT_SLUG)}...` ); const getEnvRequest = await fetch( @@ -58,8 +58,8 @@ if (getEnvRequest.status === 200) { ...extraHeaders }, body: JSON.stringify({ - name: `pr-${PR_NUMBER}`, - deploy_services: true + name: `pr-${env.PR_NUMBER}`, + deploy_services: false }) } ); @@ -81,7 +81,7 @@ if (getEnvRequest.status === 200) { } } -console.log(`Environment available in ${colors.blue(ENV_NAME)}`); +console.log(`Environment in ${colors.blue(ENV_NAME)}`); const docsService = envResponse.services.find( (srv) => srv.slug === SERVICE_SLUG @@ -93,6 +93,98 @@ if (!docsService) { process.exit(1); } +const change = { + field: "git_source", + type: "UPDATE", + new_value: { + repository_url: "https://github.com/zane-ops/docs.git", + branch_name: env.PR_BRANCH_NAME, + commit_sha: "HEAD" + } +}; + +console.log( + `Updating the branch name for the service ${colors.orange( + SERVICE_SLUG + )} in the project ${colors.orange(PROJECT_SLUG)}...` +); +const requestChangeResponse = await fetch( + `${DASHBOARD_URL}/api/projects/${PROJECT_SLUG}/${ENV_NAME}/request-service-changes/${SERVICE_SLUG}/`, + { + method: "PUT", + headers: { + "x-csrftoken": csrfToken, + cookie: requestCookie, + "content-type": "application/json", + ...extraHeaders + }, + body: JSON.stringify(change) + } +); + +if (requestChangeResponse.status !== 200) { + console.log( + colors.red("❌ Failed to update the image of the service on ZaneOps API ❌") + ); + console.log( + `Received status code from zaneops API : ${colors.red( + requestChangeResponse.status + )}` + ); + + console.log("Received response from zaneops API : "); + console.dir(await parseResponseBody(requestChangeResponse), { + depth: null + }); + // core.setFailed("Failure"); + process.exit(1); +} else { + console.log( + `Successfully Updated the repository branch to ${colors.orange(change.new_value.branch_name)} ✅` + ); +} + +console.log( + `Queuing a new deployment for the service ${colors.orange(SERVICE_SLUG)}...` +); +const deploymentResponse = await fetch( + `${DASHBOARD_URL}/api/projects/${PROJECT_SLUG}/${ENV_NAME}/deploy-service/git/${SERVICE_SLUG}/`, + { + method: "PUT", + headers: { + "x-csrftoken": csrfToken, + cookie: requestCookie, + "content-type": "application/json", + ...extraHeaders + } + } +); + +if (deploymentResponse.status >= 200 && deploymentResponse.status <= 299) { + const deployment = await deploymentResponse.json(); + console.log(`Deployment queued succesfully ✅`); + console.log( + `inspect here ➡️ ${colors.blue( + `${DASHBOARD_URL}/project/${PROJECT_SLUG}/${ENV_NAME}/services/${SERVICE_SLUG}/deployments/${deployment.hash}` + )}` + ); +} else { + console.log(colors.red("❌ Failed to queue deployment ❌")); + console.log( + `Received status code from zaneops API : ${colors.red( + deploymentResponse.status + )}` + ); + + const response = + deploymentResponse.headers.get("content-type") === "application/json" + ? await deploymentResponse.json() + : await deploymentResponse.text(); + console.log("Received response from zaneops API : "); + console.dir(response); + process.exit(1); +} + const domain = docsService.urls[0].domain; const file = Bun.file("./service-url"); const writer = file.writer(); From 19dd6a77835a3643cbdc427a5f05bb3ce5308f1d Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 03:37:38 +0200 Subject: [PATCH 04/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index 78b0298..cd32597 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -1,4 +1,4 @@ -name: Build and Push Images (DEV) +name: PR preview environment on: pull_request: workflow_dispatch: From e543e15091a8c22e494e1e755c0a8ffae0c46a42 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 04:20:43 +0200 Subject: [PATCH 05/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index cd32597..23256e6 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -18,7 +18,7 @@ jobs: - name: Install packages and Deploy to zaneops shell: bash run: | - bun install cookie-es zod@3 + bun add cookie-es zod@3 bun run scripts/deploy-pr.ts env: CF_CLIENT_ID: ${{ secrets.CF_ZONE_ID }} From c700a9508928e07e688d8300f2cec8c22e0da0fd Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 04:23:05 +0200 Subject: [PATCH 06/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index 23256e6..096b415 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -10,7 +10,13 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - + + - name: Bypass Cloudflare for GitHub Action + uses: xiaotianxt/bypass-cloudflare-for-github-action@v1.1.1 + with: + cf_zone_id: ${{ secrets.CF_ZONE_ID }} + cf_api_token: ${{ secrets.CF_API_TOKEN }} + - uses: oven-sh/setup-bun@v2 with: bun-version: latest From cb9499f0a726b066b46bd2cf3f3d7070f9083edb Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 04:24:27 +0200 Subject: [PATCH 07/12] =?UTF-8?q?=F0=9F=91=B7=20ci=20cd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index 096b415..37dcd00 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -11,12 +11,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Bypass Cloudflare for GitHub Action - uses: xiaotianxt/bypass-cloudflare-for-github-action@v1.1.1 - with: - cf_zone_id: ${{ secrets.CF_ZONE_ID }} - cf_api_token: ${{ secrets.CF_API_TOKEN }} - - uses: oven-sh/setup-bun@v2 with: bun-version: latest @@ -27,7 +21,7 @@ jobs: bun add cookie-es zod@3 bun run scripts/deploy-pr.ts env: - CF_CLIENT_ID: ${{ secrets.CF_ZONE_ID }} + CF_CLIENT_ID: ${{ secrets.CF_CLIENT_ID }} CF_CLIENT_SECRET: ${{ secrets.CF_API_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} PR_BRANCH_NAME: ${{ github.head_ref }} From e3b31191b858d19e29ce44a5679cfd9cade8ebf5 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 04:25:35 +0200 Subject: [PATCH 08/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index 37dcd00..e7b41f4 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -22,7 +22,7 @@ jobs: bun run scripts/deploy-pr.ts env: CF_CLIENT_ID: ${{ secrets.CF_CLIENT_ID }} - CF_CLIENT_SECRET: ${{ secrets.CF_API_TOKEN }} + CF_CLIENT_SECRET: ${{ secrets.CF_CLIENT_SECRET }} PR_NUMBER: ${{ github.event.pull_request.number }} PR_BRANCH_NAME: ${{ github.head_ref }} ZANE_USERNAME: ${{ secrets.ZANE_USERNAME }} From 4b41ec07befe023cf2150d095f9ca86de5db75eb Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 04:32:26 +0200 Subject: [PATCH 09/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20put=20script=20into?= =?UTF-8?q?=20their=20own=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 5 +- .github/workflows/close-pr-env.yaml | 9 +- package.json | 4 - pnpm-lock.yaml | 25 +-- scripts/.gitignore | 175 +++++++++++++++++++ scripts/README.md | 15 ++ scripts/bun.lockb | Bin 0 -> 3435 bytes scripts/deploy-pr.ts | 2 +- scripts/index.ts | 1 + scripts/package.json | 15 ++ scripts/tsconfig.json | 27 +++ tsconfig.json | 3 +- 12 files changed, 245 insertions(+), 36 deletions(-) create mode 100644 scripts/.gitignore create mode 100644 scripts/README.md create mode 100755 scripts/bun.lockb create mode 100644 scripts/index.ts create mode 100644 scripts/package.json create mode 100644 scripts/tsconfig.json diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index e7b41f4..42a715d 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -18,8 +18,9 @@ jobs: - name: Install packages and Deploy to zaneops shell: bash run: | - bun add cookie-es zod@3 - bun run scripts/deploy-pr.ts + cd scripts + bun install + bun run deploy-pr.ts env: CF_CLIENT_ID: ${{ secrets.CF_CLIENT_ID }} CF_CLIENT_SECRET: ${{ secrets.CF_CLIENT_SECRET }} diff --git a/.github/workflows/close-pr-env.yaml b/.github/workflows/close-pr-env.yaml index e660abc..7a4f723 100644 --- a/.github/workflows/close-pr-env.yaml +++ b/.github/workflows/close-pr-env.yaml @@ -19,11 +19,12 @@ jobs: - name: Close PR shell: bash run: | - bun install cookie-es zod@3 - bun run scripts/close-pr.ts + cd scripts + bun install + bun run close-pr.ts env: - CF_CLIENT_ID: ${{ secrets.CF_ZONE_ID }} - CF_CLIENT_SECRET: ${{ secrets.CF_API_TOKEN }} + CF_CLIENT_ID: ${{ secrets.CF_CLIENT_ID }} + CF_CLIENT_SECRET: ${{ secrets.CF_CLIENT_SECRET }} PR_NUMBER: ${{ github.event.pull_request.number }} ZANE_USERNAME: ${{ secrets.ZANE_USERNAME }} ZANE_PASSWORD: ${{ secrets.ZANE_PASSWORD }} diff --git a/package.json b/package.json index efb7344..9f73e5c 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,5 @@ "sharp": "^0.32.6", "tailwindcss": "^3.4.6", "typescript": "^5.5.3" - }, - "devDependencies": { - "@types/bun": "^1.2.14", - "cookie-es": "^2.0.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c5c0133..fbccd23 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -51,14 +51,6 @@ dependencies: specifier: ^5.5.3 version: 5.6.3 -devDependencies: - '@types/bun': - specifier: ^1.2.14 - version: 1.2.14 - cookie-es: - specifier: ^2.0.0 - version: 2.0.0 - packages: /@alloc/quick-lru@5.2.0: @@ -1486,12 +1478,6 @@ packages: '@babel/types': 7.26.0 dev: false - /@types/bun@1.2.14: - resolution: {integrity: sha512-VsFZKs8oKHzI7zwvECiAJ5oSorWndIWEVhfbYqZd4HI/45kzW7PN2Rr5biAzvGvRuNmYLSANY+H59ubHq8xw7Q==} - dependencies: - bun-types: 1.2.14 - dev: true - /@types/cookie@0.6.0: resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} dev: false @@ -1540,6 +1526,7 @@ packages: /@types/node@17.0.45: resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} + dev: false /@types/prop-types@15.7.13: resolution: {integrity: sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA==} @@ -2001,12 +1988,6 @@ packages: ieee754: 1.2.1 dev: false - /bun-types@1.2.14: - resolution: {integrity: sha512-Kuh4Ub28ucMRWeiUUWMHsT9Wcbr4H3kLIO72RZZElSDxSu7vpetRvxIUDUaW6QtaIeixIpm7OXtNnZPf82EzwA==} - dependencies: - '@types/node': 17.0.45 - dev: true - /camelcase-css@2.0.1: resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==} engines: {node: '>= 6'} @@ -2152,10 +2133,6 @@ packages: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} dev: false - /cookie-es@2.0.0: - resolution: {integrity: sha512-RAj4E421UYRgqokKUmotqAwuplYw15qtdXfY+hGzgCJ/MBjCVZcSoHK/kH9kocfjRjcDME7IiDWR/1WX1TM2Pg==} - dev: true - /cookie@0.7.2: resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} engines: {node: '>= 0.6'} diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 0000000..9b1ee42 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..b8d932e --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,15 @@ +# scripts + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.1.45. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/scripts/bun.lockb b/scripts/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..dfc426f85905ed21f7f69d7bd09edfed2f59a95d GIT binary patch literal 3435 zcmd5;YfKbZ6rP0@a0Pjat5JS41s7M6MCQ|5Fhd=FXSCzAj2Nr zzZ$;RwHFcpp9Xv)!p1A47Wd}lS}L~(WZyTE7v_C!+5KruW!>7UL#O<2E?lC&*m(Et zG3`eKEj|I^9lJW;xgEde-C?8MD^;1}&OO{$|NboB>jGYU?kH{XY^NU2O_dROE6YBX zM5d5mI8*zh<-eAEnZEkM1NREEPpf_auaqpb%af^m%rDXA5{2wQPIz; z;7|dtux{e$V@m>l^!NX;`G!X3=5L-<;_-Q9DYrf^dURX-{^eJg86Cx{n2MIxG4~Bp zRZZ&IBdyy>sf)J#{=Gk&4xBa#^Tllc)5ga`)kC~37zFW#nn@D7VOw^`JXsdogiP-AK1k1EB?Jc zC7bP#`a4`Tl~;YgKjUntv}dO|90HqO6P|DYh@5_LE^#I88! zT1RSil;g^lLIE%8H*Dfhh}JR}HzMWAUGJ~1u9@`HnIml0-nl!MO*-gS+I{>FCUD)! zyc4B6bn9BCZGK~+nG}!pO;c~soJ_mW#4SAg$WOrgMBkP!j*r>fB|CSgn_X4w>D=w< zT)%PZvaT7wO#GpJm(!R8^WiqX`3n|*G%|c?*Z7N9&(!!&AGWzQOtv9;MRj?PYZmYh zCBrqw{$+9-Vq1EdEeuJ_A^sn~f%g&(%V;T`f#u@#dJ4-8DvF`$P^nTbWp&xKF>$gq zP#UM#B^iu~ND%PW``Bh^iu(B`&*==p0hvUTu2O~q^cf_m#_0D8{nnsfLEkX?-qbuk zY7jhVU4%zGh)>9q&*MY+oF$qVW$^NJHEb-nFDJ#*8$)^r>k>CnY!D@_h>uGBT{W zuy(Q&tqG=-3P>&=B?s2b`zNc)(rFnqL(R$LXvPqy|A1q3hNMubqW=)oeTTrYS}RlC zL$7_z)&egiNYOLbOM5ik<5pF1EK4)Mw*0(wZDiuSo-J_bNC)PrgHDSwNA~vc8Jy=8 zDD(iFx8j+{&1IQroA#V(y_JFL)f$bdI+~=}WR5ejAu<_5C+S#@$)XIVv=o*yGD$Kx zSs970B!8e3my|s~d><#E`tC_= 200 && deploymentResponse.status <= 299) { console.log(`Deployment queued succesfully ✅`); console.log( `inspect here ➡️ ${colors.blue( - `${DASHBOARD_URL}/project/${PROJECT_SLUG}/${ENV_NAME}/services/${SERVICE_SLUG}/deployments/${deployment.hash}` + `${DASHBOARD_URL}/project/${PROJECT_SLUG}/${ENV_NAME}/services/${SERVICE_SLUG}/deployments/${deployment.hash}/build-logs` )}` ); } else { diff --git a/scripts/index.ts b/scripts/index.ts new file mode 100644 index 0000000..f67b2c6 --- /dev/null +++ b/scripts/index.ts @@ -0,0 +1 @@ +console.log("Hello via Bun!"); \ No newline at end of file diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 0000000..0836670 --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,15 @@ +{ + "name": "scripts", + "module": "index.ts", + "type": "module", + "devDependencies": { + "@types/bun": "^1.2.14" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "cookie-es": "^2.0.0", + "zod": "^3.25.28" + } +} \ No newline at end of file diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 0000000..238655f --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +} diff --git a/tsconfig.json b/tsconfig.json index b7243b9..2cc8a25 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,5 +3,6 @@ "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "react" - } + }, + "exclude": ["scripts/**"] } From b5cc7ae9ff832b5f9939be9cbebd26763ffc6b58 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 04:43:32 +0200 Subject: [PATCH 10/12] =?UTF-8?q?=F0=9F=91=B7=20comment=20on=20PR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index 42a715d..ef2051d 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -29,3 +29,16 @@ jobs: ZANE_USERNAME: ${{ secrets.ZANE_USERNAME }} ZANE_PASSWORD: ${{ secrets.ZANE_PASSWORD }} + - name: Read service URL + id: read_url + run: | + url=$(cat ./scripts/service-url) + echo "url=$url" >> $GITHUB_OUTPUT + + - name: Comment on PR + uses: unsplash/comment-on-pr@v1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: 🚀 **PR Preview URL:** ${{ steps.read_url.outputs.url }} + check_for_duplicate_msg: true \ No newline at end of file From 3fb227818d5a3a2e02349e527c5ce19552eeee02 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 05:02:57 +0200 Subject: [PATCH 11/12] =?UTF-8?q?=F0=9F=91=B7=20ci=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index ef2051d..4a7863e 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -38,7 +38,7 @@ jobs: - name: Comment on PR uses: unsplash/comment-on-pr@v1.3.0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.COMMENT_PAT }} with: msg: 🚀 **PR Preview URL:** ${{ steps.read_url.outputs.url }} check_for_duplicate_msg: true \ No newline at end of file From aeb8f0900d6efeee551770b1bb9e77675caf93b8 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Sun, 25 May 2025 05:10:42 +0200 Subject: [PATCH 12/12] =?UTF-8?q?=F0=9F=91=B7=20refactor=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push-images-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-push-images-dev.yaml b/.github/workflows/build-push-images-dev.yaml index 4a7863e..3578e7a 100644 --- a/.github/workflows/build-push-images-dev.yaml +++ b/.github/workflows/build-push-images-dev.yaml @@ -40,5 +40,5 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.COMMENT_PAT }} with: - msg: 🚀 **PR Preview URL:** ${{ steps.read_url.outputs.url }} + msg: 🚀 **PR Preview URL:** https://${{ steps.read_url.outputs.url }} check_for_duplicate_msg: true \ No newline at end of file