Skip to content

feat(non-github scm): Initial sounding-out of non-github SCM support#48

Closed
AmandaCameron wants to merge 3 commits intoupdatecli:mainfrom
AmandaCameron:non-github-scm
Closed

feat(non-github scm): Initial sounding-out of non-github SCM support#48
AmandaCameron wants to merge 3 commits intoupdatecli:mainfrom
AmandaCameron:non-github-scm

Conversation

@AmandaCameron
Copy link

@AmandaCameron AmandaCameron commented Jun 28, 2025

Example alternate solution to updatecli/updatecli#5461

Description

This PR is an example of how I think we could easily make non-github SCMs work for this repo.

Test

To use this on, for example, codeberg.org:

scm:
  enabled: true
  kind: gitea
  url: https://codeberg.org
  username: your-updatecli-bot
  token_env: UPDATECLI_CODEBERG_TOKEN
  owner: some
  repository: repo
  branch: main

labels: false
automerge: false

action:
  kind: gitea/pullrequest

Additional Information

Tradeoff

This makes the configuration somewhat more complex for non-github users, but it doesn't break existing github users. ( At least, it shouldn't, unless I missed something)

Potential improvement

This should allow any SCM to be used that is supported by updatecli, without a bunch of if-else's for different SCMs

@AmandaCameron AmandaCameron changed the title Draft: feat(non-github scm): Initial sounding-out of non-github SCM support WIP: feat(non-github scm): Initial sounding-out of non-github SCM support Jun 28, 2025
@AmandaCameron AmandaCameron changed the title WIP: feat(non-github scm): Initial sounding-out of non-github SCM support feat(non-github scm): Initial sounding-out of non-github SCM support Jun 28, 2025
@AmandaCameron AmandaCameron marked this pull request as draft June 28, 2025 12:27
@olblak
Copy link
Member

olblak commented Jul 2, 2025

Hey @AmandaCameron,

Sorry for the late reply, busy week and I wanted to have some time to formalize what I have in mind.
With the "partial" concept introduced in updatecli/updatecli#5508

I was considering moving each scm configuration to one scm partial file per scm kind.

For example:

_scm.github.yaml
# {{ if and (.scm.enabled) ( eq .scm.kind "github")) }}
# {{ $GitHubUser := env ""}}
# {{ $GitHubUsername := env "GITHUB_ACTOR"}}
# {{ $GitHubRepositoryList := env "GITHUB_REPOSITORY" | split "/"}}
# {{ $GitHubPAT := env "GITHUB_TOKEN"}}

actions:
    default:
        title: 'deps: bump HUGO to {{ source "hugo" }}'
        kind: "github/pullrequest"
        spec:
            automerge: {{.automerge}}
            # {{ if .labels }}
            labels:
                # {{ range .labels }}
                - ' {{ . }}'
                # {{ end }}
            # {{ end }}
            mergemethod: "squash"
        scmid: "default"
scms:
    default:
        kind: "github"
        spec:
            # Priority set to the environment variable
            user: '{{ default .scm.user }}'
            # {{ if .scm.email }}
            email: '{{ .scm.email }}'
            # {{ end }}
            owner: '{{ default $GitHubRepositoryList._0 .scm.owner }}'
            repository: '{{ default $GitHubRepositoryList._1 .scm.repository }}'
            token: '{{ default $GitHubPAT .scm.token }}'
            username: '{{ default $GitHubUsername  .scm.username }}'
            branch: '{{ .scm.branch }}'
            # {{ if .scm.commitusingapi }}
            commitusingapi: {{.scm.commitusingapi}}
            # {{ end }}
# {{ end }}
_scm.gitea.yaml
# {{ if and (.scm.enabled) ( eq .scm.kind "gitea")) }}
actions:
    default:
        title: 'deps: bump HUGO to {{ source "hugo" }}'
        kind: "gitea/pullrequest"
        scmid: "default"

scms:
    default:
        kind: "gitea"
        spec:
            user: '{{ .scm.user }}'
            # {{ if .scm.email }}
            email: '{{ .scm.email }}'
            # {{ end }}
            owner: '{{ .scm.owner }}'
            repository: '{{ .scm.repository }}'
            token: '{{ .scm.token }}'
            username: '{{ .scm.username }}'
            branch: '{{ .scm.branch }}'
            # {{ if .scm.url }}
            url: '{{ .scm.url }}'
            # {{ end }}
# {{ end }}

I think it would be easier to maintain and will require less yaml code for policies containing multiple manifest

@olblak
Copy link
Member

olblak commented Jul 3, 2025

Here is an example of a test policy leveraging the partial feature
#49

@olblak olblak marked this pull request as ready for review July 7, 2025 06:50
@olblak
Copy link
Member

olblak commented Jul 7, 2025

Closing in favor of #49

@olblak olblak closed this Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants