sharpliner / sharpliner

Use C# instead of YAML to define your Azure DevOps pipelines
https://www.nuget.org/packages/Sharpliner/
MIT License
285 stars 21 forks source link

Please support GitHub Actions #239

Open gregory-seidman opened 1 year ago

gregory-seidman commented 1 year ago

This is great for Azure DevOps, but GitHub Actions workflow definitions are at least a bit different. I'm not sure how much work would be involved, exactly, but I'd love to see support for GHA.

gregory-seidman commented 1 year ago

I just found the work in progress on it. I guess this issue should just be considered a vote of support for continuing that work. If I have time I'll try to contribute.

premun commented 1 year ago

Hi @gregory-seidman, Thanks for opening the issue. The GitHub actions work was started by a friend but he never got around to finishing it. There is a considerable coverage of the GH model in the repo already though. However, I am not sure how usable it is at the moment.

I would like to have the support in Sharpliner but I don't use GitHub actions personally so I don't have the right experience to create something handy and usable though I understand the GitHub actions YAML is much more simple than Azure DevOps. I haven't checked what type of expressions and similar are available so would have to do some reading.

However, if you consider contributing, I can definitely help plugging the current Actions models with the YAML generation process that is already in place for AzDO so that you have an E2E solution to play with and then it's just a question of getting to 100% with the coverage of the GHA model.

Is this something you'd be interested in?

gregory-seidman commented 1 year ago

I am interested, but I am not sure I can dedicate the time to it. I'll start by forking the repo, at least.

premun commented 1 year ago

To start, you need to make the classes from the GitHubActions namespace public. Something like this: https://github.com/premun/sharpliner/commit/a02ff0fb84009417160f26f2d7d6ebaa94156408

Then, you can maybe try to add a definition for the workflow that is already in the repo:

class CodeQLAnalysisWorkflow : WorkflowDefinition
{
    public override string TargetFile => ".github/workflows/codeql-analysis.yml";

    public override TargetPathType TargetPathType => TargetPathType.RelativeToGitRoot;

    public override Workflow Workflow => new()
    {
        Name = "CodeQL",

        On = new()
        {
            Push = new()
            {
                Branches = { "main" },
            },
            PullRequest = new()
            {
                Branches = { "main" },
            },
        },

        Jobs =
        {
            new Job("Analyze")
            {
                RunsOn = "ubuntu-latest",

                Steps =
                {
                    ...
            },
        }
    };
}

and see where it gets you. I expect many things will be missing.