Skip to content

feat: add GitHub action autodiscovery plugin#1964

Merged
olblak merged 29 commits intoupdatecli:mainfrom
olblak:add/autodiscovery/githubaction
Nov 4, 2024
Merged

feat: add GitHub action autodiscovery plugin#1964
olblak merged 29 commits intoupdatecli:mainfrom
olblak:add/autodiscovery/githubaction

Conversation

@olblak
Copy link
Copy Markdown
Member

@olblak olblak commented Feb 29, 2024

This pullrequest add a new autodiscovery plugin for handling GitHub action update
It supports both the GitHub action and Gitea variant.

Here is an example of configuration

autodiscovery:
  scmid: default
  actionid:  default
  crawlers:
    github/action:
      credentials:
        "code.forgejo.com":
          kind: gitea
          token: yyyy
        "github.com":
          kind: github
          token: '{{ requiredEnv "GITHUB_TOKEN" }}'
      versionfilter:
        kind: semver
        pattern: minor
      only:
        - actions:
            "updatecli/updatecli-action": ""

Please note that credentials are fetched from the environment variable by default.

For 'github.com', the default value is set to first environment detected

  1. "UPDATECLI_GITHUB_TOKEN"
  2. "GITHUB_TOKEN"

For 'gitea.com' and 'codeberg.org', the default value is set to first environment detected

  1. "UPDATECLI_GITHUB_TOKEN"
  2. "GITEA_TOKEN"

Test

To test this pull request, you can run the following commands:

go test ./pkg/plugins/autodiscovery/githubaction/
go build -o bin/updatecli .
./bin/updatecli diff --config e2e/updatecli.d/success.d/autodiscovery/github/action

Additional Information

Tradeoff

/

Potential improvement

Potential improvement would be to improve the gitearelease and githubrelease Updatecli plugin to work without credentials such as #1417.

Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added autodiscovery All things related to the autodiscovery feature enhancement New feature or request labels Feb 29, 2024
@olblak olblak marked this pull request as draft March 26, 2024 19:56
@olblak olblak closed this Apr 3, 2024
@olblak olblak deleted the add/autodiscovery/githubaction branch April 3, 2024 18:47
@olblak olblak restored the add/autodiscovery/githubaction branch July 10, 2024 06:43
@olblak olblak reopened this Jul 10, 2024
@olblak olblak added this to the 0.86.0 milestone Oct 17, 2024
@olblak olblak marked this pull request as ready for review October 17, 2024 07:43
olblak and others added 5 commits October 17, 2024 09:57
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak
Copy link
Copy Markdown
Member Author

olblak commented Oct 30, 2024

Spotted an interesting issue when using on Gitea/Forgejo.
I tested on https://codeberg.org/olblak/Reusable-workflows and realize that the way we control credentials can't work

olblak and others added 5 commits November 1, 2024 22:24
This commit also clean up spec comment and remove unused token variable

Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak
Copy link
Copy Markdown
Member Author

olblak commented Nov 2, 2024

I think I spot a bug.
It fails if the filename contains empty space

ERROR: .forgejo/workflows/Build container image.yaml: the yaml file does not exist

The problem is probably not related to the current pullrequest but instead after the go templating that remove single quotes around the file name

Comment thread pkg/core/pipeline/autodiscovery/main.go
@olblak
Copy link
Copy Markdown
Member Author

olblak commented Nov 4, 2024

Thanks @loispostula for the hints.
I forgot to set the scmid in new manifests, so it tried to update local files instead of those located on the git repository, hence the error.
It now works as I could open this pullrequest https://github.com/updatecli-test/github-actions/pull/1/files

Also, I added the ability to use either "github/action" or "gitea/action" but only "github/action" is enabled by default in the autodiscovery as it would otherwise generate duplicated manifest.

@olblak
Copy link
Copy Markdown
Member Author

olblak commented Nov 4, 2024

I think the pullrequest is now ready.

@olblak olblak enabled auto-merge (squash) November 4, 2024 07:54
@olblak olblak merged commit 57deeab into updatecli:main Nov 4, 2024
@olblak olblak deleted the add/autodiscovery/githubaction branch November 4, 2024 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autodiscovery All things related to the autodiscovery feature enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants