1 Commits

Author SHA1 Message Date
dfb6b0fb6d move to deno 2024-12-15 22:55:42 +01:00
7 changed files with 7 additions and 40 deletions

View File

@@ -1,11 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

View File

@@ -9,15 +9,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Docker Labels
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@v4
with:
images: |
cupcakearmy/gitea-sync
@@ -30,19 +30,19 @@ jobs:
type=semver,pattern={{major}}
- name: Log in to Docker Hub
uses: docker/login-action@v3
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
# - name: Log in to the Container registry
# uses: docker/login-action@v3
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
push: true

View File

@@ -33,12 +33,6 @@ GITEA_TOKEN=
# Cron schedule
CRON="0 */2 * * *"
# Debug level
DEBUG_LEVEL=debug
# Only run one, skip cron and exit
RUN_ONCE=1
```
## Known limitations

BIN
bin Executable file

Binary file not shown.

View File

@@ -35,6 +35,5 @@ export const Config = {
token: simple('GITEA_TOKEN'),
},
cron: getEnv('CRON', '0 */2 * * *'),
runOnce: getEnv('RUN_ONCE', false, Boolean),
version: getEnv('npm_package_version', 'unknown'),
}

View File

@@ -18,14 +18,10 @@ export async function sync() {
const toSync = await githubRepos()
l.debug('loaded repos', { remote: toSync.length, local: syncedRepos.length })
// List of all the repos in gitea, that are not on github
const notInSource = new Set(syncedRepos.map((r) => r.name))
for (const repo of toSync) {
const lr = l.child({ repo: repo.name })
const sameName = syncedRepos.find((r) => r.name === repo.name || r.original_url === repo.clone_url)
if (sameName) {
notInSource.delete(sameName.name)
if (sameName.original_url === repo.clone_url) {
if (sameName.private === repo.private) logger.info('Already synced, skipping', { name: repo.name })
else {
@@ -56,9 +52,6 @@ export async function sync() {
await mirror(options)
lr.info('mirrored repository')
}
if (notInSource.size) {
l.info(`Found ${notInSource.size} surplus repositories in gitea`, { repos: [...notInSource] })
}
l.info('Finished sync')
} catch (error) {
l.debug(error)

View File

@@ -6,13 +6,5 @@ import { logger } from './logger.ts'
logger.info(`Mirror manager - ${Config.version}`, { version: Config.version })
Deno.addSignalListener('SIGINT', () => {
console.log('exiting...')
Deno.exit()
})
// Run on startup once, then delegate to cron
await sync()
if (!Config.runOnce) {
cron.schedule(Config.cron, sync)
}
cron.schedule(Config.cron, sync)