Skip to content
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

support: load config from external repository #618

Open
3 tasks done
alombarte opened this issue Sep 29, 2022 · 9 comments
Open
3 tasks done

support: load config from external repository #618

alombarte opened this issue Sep 29, 2022 · 9 comments
Assignees
Labels
enhancement New feature or request proposal
Milestone

Comments

@alombarte
Copy link

alombarte commented Sep 29, 2022

Checklist

  • I am using the latest version of this action.
  • I have read the latest README and followed the instructions.
  • I have read the latest GitHub Actions official documentation and learned the basic spec and concepts.

Describe your question

Hi,

I was testing the action and I got the impression that the configuration file is always assumed to live inside the repository whose job is calling the action. When using the special .github repository (not folder) along with the health files and other cross-organization workflows, the action fails to load the configuration.

For instance, in your github.com/ORGANIZATION/.github repository, you have a file github.com/ORGANIZATION/.github/.github/workflows/label-commenter.yml with content:

name: Label Commenter

on:
  workflow_call:

permissions:
  contents: read
  issues: write
  pull-requests: write

jobs:
  comment:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v3

      - name: Label Commenter
        uses: peaceiris/actions-label-commenter@v1

The on specifies the calling from outside. And then you have the config in its default location, also inside the .github repo. Then you call it from another repo (github.com/ORGANIZATION/some-repo) with its workflow:

name: Label commenter
on:
  issues:
    types: [labeled, unlabeled]
  pull_request_target:
    types: [labeled, unlabeled]
jobs:
  stale:
    uses: ORGANIZATION/.github/.github/workflows/label-commenter.yml@main

The configuration file will fail to load as it is looking from within the calling repo, but the config lives centralized with the label commenter action.

Is there a way to specify a different organization and repo to load the configuration file, or to load it embedded using with or similar in one file? Otherwise the configuration file has to be copied in all repos of the organization.

Thank you!

Relevant links

YAML config: https://github.com/krakendio/.github/blob/48caa81a3c9159759f064976665631d6f5e9bb83/.github/label-commenter-config.yml
YAML workflow: https://github.com/krakendio/krakend-schema/blob/1dd2ccfe75bcfb7778a1340f0ef413da93a368ef/.github/workflows/labels.yml

Relevant log output

Action failed with error "not found .github/label-commenter-config.yml"

Additional context.

No response

@alombarte alombarte added the support User support label Sep 29, 2022
@alombarte
Copy link
Author

Hi @peaceiris, I see your 👀 reaction to the issue, but I am not very good at analyzing emoji reactions. Is there something unclear or questions you have about it?

I think this action is very useful (thank you for that!), and the ability to use it centralized for all repos of an organization would be awesome.

@peaceiris
Copy link
Owner

Thank you for your great suggestion!

A few months ago, I considered remaking the config_file input to fetch a custom remote config file like https://github.com/actions/labeler. That was the plan in my mind. It can satisfy your demand.

I will work on this in the next major version v2 https://github.com/peaceiris/actions-label-commenter/milestone/2

@peaceiris peaceiris added enhancement New feature or request proposal and removed support User support labels Oct 4, 2022
@peaceiris peaceiris added this to the v2.0.0 milestone Oct 4, 2022
@actions-label-commenter
Copy link

Hi, there.

Thank you @alombarte for suggesting this.


This is an automated comment created by the peaceiris/actions-label-commenter. Responding to the bot or mentioning it won't have any effect.

@peaceiris
Copy link
Owner

The new config_file has been already implemented, but not released.
You can try it with c2d0066.

async loadConfig(runContext: IContext, githubClient: InstanceType<typeof GitHub>): Promise<any> {

- uses: peaceiris/actions-label-commenter@c2d00660c86f2b9ed0fb35b372c451558eba85b3

alombarte added a commit to krakend/.github that referenced this issue Oct 4, 2022
alombarte added a commit to krakend/krakend-schema that referenced this issue Oct 4, 2022
@alombarte
Copy link
Author

alombarte commented Oct 4, 2022

Hi @peaceiris ,

I am amazed with your responsiveness.... this is so cool!

I have added the commit SHA to a test workflow, and here is the error log:
https://github.com/krakendio/krakend-schema/actions/runs/3183610933/jobs/5191036905

With the follwoing lines

uses: peaceiris/actions-label-commenter@c2d00660c86f2b9ed0fb35b372c451558eba85b3
        with:
          config_file: krakendio/.github/.github/label-commenter-config.yml@main

The log is:

Run peaceiris/actions-label-commenter@c2d00660c86f2b9ed0fb35b372c451558eba85b3
Version 6a5e75862c79ac87748dc7e71c43b7ab5cb0def0
Usage https://github.com/peaceiris/actions-label-commenter#readme
Dump GitHub context
Event name: issues
Dump runContext
Dump error.stack
Error: Not Found

alombarte added a commit to krakend/.github that referenced this issue Oct 4, 2022
@peaceiris
Copy link
Owner

Ahh, maybe the called workflow runs on krakendio/krakend-schema, not krakendio/.github

I will add support fetching a file with the HTTPS protocol for that case.

      - uses: peaceiris/actions-label-commenter@v2
        with:
          config_file: https://github.com/krakendio/.github/blob/main/.github/label-commenter-config.yml
          # or config_file: https://raw.githubusercontent.com/krakendio/.github/main/.github/label-commenter-config.yml

alombarte added a commit to krakend/.github that referenced this issue Oct 4, 2022
@alombarte
Copy link
Author

That's correct. The idea is having a single configuration file centralized in the .github repository. The rest of repositories in the organization are going to load this one.

I am eager to see this implemented, and in fact I will wait until it's done to apply it to all the projects (~50) at once.

Thanks!

alombarte added a commit to krakend/krakend-schema that referenced this issue Oct 17, 2022
@alombarte
Copy link
Author

alombarte commented Jan 13, 2023

Hi @peaceiris , I was wondering if you had a look to retrieving the config_filefrom a remote location. I am not pushing or anything, the action is very good, and I will do copy/paste if needed to enable it in the rest of the projects.

@alombarte
Copy link
Author

Hello @peaceiris ,

Are there any plans to support this functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request proposal
Projects
None yet
Development

No branches or pull requests

2 participants