Skip to content

feat: adding aplCharts version support #2401

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

Merged
merged 12 commits into from
Aug 7, 2025
Merged
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
30 changes: 18 additions & 12 deletions src/cmd/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { terminal } from 'src/common/debug'
import { env, isCi } from 'src/common/envalid'
import { hfValues } from 'src/common/hf'
import { createGenericSecret, k8s, waitTillGitRepoAvailable } from 'src/common/k8s'
import { getFilename } from 'src/common/utils'
import { getFilename, loadYaml } from 'src/common/utils'
import { getRepo } from 'src/common/values'
import { getParsedArgs, HelmArguments, setParsedArgs } from 'src/common/yargs'
import { Argv } from 'yargs'
Expand All @@ -19,6 +19,8 @@ import { validateValues } from './validate-values'

const cmdName = getFilename(__filename)

export const rootDir = process.cwd() === '/home/app/stack/env' ? '/home/app/stack' : process.cwd()

interface Arguments extends HelmArguments, DroneArgs {
m?: string
message?: string
Expand Down Expand Up @@ -130,22 +132,24 @@ export const commit = async (initialInstall: boolean, overrideArgs?: HelmArgumen

export const cloneOtomiChartsInGitea = async (): Promise<void> => {
const d = terminal(`cmd:${cmdName}:gitea-apl-charts`)
d.info('Checking if apl-charts already exists in Gitea')
const versions = await loadYaml(`${rootDir}/versions.yaml`, { noError: true })
const tag = versions?.aplCharts
d.info(`Checking if apl-charts tag '${tag}' already exists in Gitea`)
const values = (await hfValues()) as Record<string, any>
const { email, username, password } = getRepo(values)
const workDir = '/tmp/apl-charts'
const otomiChartsUrl = env.OTOMI_CHARTS_URL
const giteaChartsUrl = `http://${username}:${password}@gitea-http.gitea.svc.cluster.local:3000/otomi/charts.git`
try {
// Check if remote repository exists by verifying if output from git ls-remote is not empty
const repoExists = await $`git ls-remote ${giteaChartsUrl}`
if (repoExists.stdout.trim()) {
d.info('apl-charts repository already exists in Gitea. Skipping clone and initialization steps.')
// Check if the tag exists in the remote Gitea repository
const tagExists = await $`git ls-remote --tags ${giteaChartsUrl} refs/tags/${tag}`
if (tagExists.stdout.trim()) {
d.info(`Tag '${tag}' already exists in Gitea. Skipping clone and initialization steps.`)
return
}
d.info('Cloning apl-charts in Gitea')
await $`mkdir ${workDir}`
await $`git clone --depth 1 ${otomiChartsUrl} ${workDir}`
d.info(`Cloning apl-charts at tag '${tag}' from upstream`)
await $`mkdir -p ${workDir}`
await $`git clone --branch ${tag} --depth 1 ${otomiChartsUrl} ${workDir}`
cd(workDir)
await $`rm -rf .git`
await $`rm -rf deployment`
Expand All @@ -158,14 +162,16 @@ export const cloneOtomiChartsInGitea = async (): Promise<void> => {
await setIdentity(username, email)
await $`git checkout -b main`
await $`git add .`
await $`git commit -m "first commit"`
await $`git commit -m "first commit for tag ${tag}"`
await $`git tag ${tag}`
await $`git remote add origin ${giteaChartsUrl}`
await $`git config http.sslVerify false`
await $`git push -u origin main`
await $`git push origin ${tag}`
} catch (error) {
d.info('CloneOtomiChartsInGitea Error ', error?.message?.replace(password, '****'))
d.info('cloneOtomiChartsInGitea Error ', error?.message?.replace(password, '****'))
}
d.info('Cloned apl-charts in Gitea')
d.info(`Cloned apl-charts at tag '${tag}' in Gitea`)
}

export async function retryIsOAuth2ProxyRunning() {
Expand Down
1 change: 1 addition & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ console: main
consoleLogin: main
tasks: main
tools: main
aplCharts: main
Loading