Git Product home page Git Product logo

photon's Introduction

Photon

A platform for packaging and deploying .NET-based automation scripts to provide a complete pipeline-as-code solution for building, testing, and deploying projects.

Photon packages your custom .NET library with your applications, allowing users to build, test, and deploy their applications with the full power of .NET! By managing your custom libraries alongside your projects, you can gain full support for branch versioning of your automated tasks. This allows users to make structural project changes that alter their pipelines, without affecting other branches of code!

Since standard .NET libraries are used, you can leverage the full user experience of Visual Studio when editing your pipelines. By decorating your scripts and tasks with test attributes, you can even make your tasks directly runnable and debuggable using your favorite testing platform.

Visit the Official Website to download releases and view the documentation.

Usage example

Scripts : IScript

Scripts are run on the Server, and are primarily used to delegate work to agents. In the below script, we register all agents matching the roles Configuration.Roles.Deploy.Web and Configuration.Roles.Deploy.Service, which are pre-defined string constants.

public class DeployScript : IScript
{
    public async Task<ScriptResult> RunAsync(ScriptContext context)
    {
        var agents = context.RegisterAgents(
            "role.deploy.web",
            "role.deploy.Service");

        try {
            await agents.InitializeAsync();

            // Unpack Applications
            await agents.RunTasksAsync(
                nameof(UnpackPhotonSampleWeb),
                nameof(UnpackPhotonSampleService));

            // Update Applications
            await agents.RunTasksAsync(
                nameof(UpdatePhotonSampleWeb),
                nameof(UpdatePhotonSampleService));
        }
        finally {
            await agents.ReleaseAllAsync();
        }
    }
}

Tasks are run on Agents. By specifying the [Roles] attribute, tasks can be limited to Agents matching those roles. This allows multiple tasks to be executed simultaneously while only executing on agents matching their role.

[Roles(Configuration.Roles.Deploy.Web)]
internal class UnpackPhotonSampleWeb : IDeployTask
{
    public IAgentDeployContext Context {get; set;}

    public async Task<TaskResult> RunAsync()
    {
        // Get the versioned application path
        var applicationPath = Context.GetApplicationDirectory(Configuration.Apps.Web.AppName, Context.ProjectPackageVersion);

        // Download Package to temp file
        var packageFilename = await Context.PullApplicationPackageAsync(Configuration.Apps.Web.PackageId, Context.ProjectPackageVersion);

        // Unpackage contents to application path
        await ApplicationPackageTools.UnpackAsync(packageFilename, applicationPath);
    }
}
[Roles(Configuration.Roles.Deploy.Web)]
internal class UpdatePhotonSampleWeb : IDeployTask
{
    public IAgentDeployContext Context {get; set;}

    public async Task RunAsync()
    {
        // Get the versioned application path
        var applicationPath = Context.GetApplicationDirectory(Configuration.Apps.Web.AppName, Context.ProjectPackageVersion);

        using (var iis = new IISTools(Context)) {
            // Configure and start AppPool
            iis.ApplicationPool.Configure(Configuration.AppPoolName, pool => {
                pool.AutoStart = true;
                pool.ManagedPipelineMode = ManagedPipelineMode.Integrated;
                pool.ManagedRuntimeVersion = "v4.0";

                if (pool.State == ObjectState.Stopped)
                    pool.Start();
            });

            // Configure and start Website
            iis.WebSite.Configure("Photon Web", 8086, site => {
                site.ApplicationDefaults.ApplicationPoolName = Configuration.AppPoolName;
                site.ServerAutoStart = true;

                // Set Bindings
                site.Bindings.Clear();
                site.Bindings.Add("*:8086:localhost", "http");

                // Update Virtual Path
                site.Applications[0]
                    .VirtualDirectories["/"]
                    .PhysicalPath = applicationPath;

                if (site.State == ObjectState.Stopped)
                    site.Start();
            });
        }
    }
}

Release History

  • 0.0.1
    • Initial Release; Work in progress.

Meta

Joshua Miller - null511@GitHub โ€“ mailto:[email protected]

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Fork it (https://github.com/Photon-CI/Photon/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

photon's People

Contributors

brhoten avatar null511 avatar photonagent avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.