Giter Club home page Giter Club logo

pwsh-github-action-base's Introduction

pwsh-github-action-base

Base support for implementing GitHub Actions in PowerShell Core

โญ I appreciate your star, it helps me decide to which OSS projects I should allocate my spare time.


GitHub Workflow - CI GitHub release (latest by date) Pester Tests


This repository contains a bundle of files to support creating GitHub Actions in PowerShell Core that can be executed across all the supported platforms where GitHub Workflows are executed.

The distribution includes a number of base components:

  • _init/index.js - The entry point into invoking the Action.
  • SAMPLE-action.ps1 - A sample script implementing a simple Action script demonstrating some of the features made available from the Core library.
  • SAMPLE-action.yml - A sample Action metadata file that describes various attributes such as a description, licensing, branding and formal input and output values.

Additionally, the sample Action shows how to make use of the GitHubActions module to get access to the GH Actions/Workflow environment for input, output and messaging. More details can be found below

Required Components

action.ps1 - The PowerShell Entry Point

You create an Action by creating a PowerShell script named action.ps1, this the the main entry point into your Action logic. From here you can inspect for, and assemble inputs and environment variables, call into other processes in the local environment context, and issue commands to the Action/Workflow context to perform logging and adjust the state of the job as seen by subsequent Actions and Steps.

You can also make calls out to external services via APIs, including calling into the GitHub API.

action.yml - The Action Metadata

As per the GitHub Actions mechanism, you must provide a metadata file that describes various attributes about your Action, including any formal inputs and outputs. You use this metadata file to enumerate any required inputs that must be provided by a Workflow definition.

runs Entry Point Attribute

The most important attribute in this file for our purposes is the runs setting which has two child settings, using and main. This attribute indicates what is the type of your Action and how to run it.

There are two main types of Actions, one based on Docker containers and one based on JavaScript (NodeJS). While Docker Actions give you the ability to define and carry the entire runtime with you, they are slower to start and limited to only executing in Linux environments.

JavaScript Actions however are simpler and more lightweight, and therefore quicker to start, and they can run on any of the supported platforms (Linux, Windows, MacOS). They also execute directly in the hosted virtual machine where the Workflow runs instead of a dedicated container.

Because of these advantages, this repo hosts a solution that is based on JavaScript-type Actions. A stub JavaScript script is provided to bootstrap the Action entry point and then immediately switches over to your provided PowerShell script. To use this bootstrap script, you need to specify the following runs attribute in your actions.yml metadata file:

runs:
  using: node12
  main: _init_/index.js

This configuration assumes you have placed the bootstrap JavaScript file in a _init subdirectory within your Action root directory. The bootstrap code also assumes this subdirectory location. If you decide to place it elsewhere or otherwise rename it, make sure to adjust the metadata file appropriately, and update the bootstrap script logic to accommodate any path changes.

_init/index.js

As mentioned above the _init/index.js file is a bootstrap JavaScript file that is used as the initial main entry point into your custom Action. After starting, it immediately transfers control to your PowerShell script by invoking the file action.ps1 in the directory immediately above the _init subdirectory. The invocation is equivalent to the following command-line call:

pwsh -f /full/path/to/action.ps1

The working directory is the same as at the start of the bootstrap script which is the root of the cloned repository of the Workflow in which the action is being invoked.

Optional Support Module

In addition to the required components above, you may choose to make use of the GitHubActions PowerShell module utility script that defines a number of cmdlets that help interact with the Worklfow/Action environment context in a more natural way for PowerShell scripts. These cmdlets are adaptations of the JavaScript Actions core package provided in the Actions Toolkit. See that package description for details about what it provides

For details about the counterpart cmdlets, go to the docs.

pwsh-github-action-base's People

Contributors

ash258 avatar dependabot[bot] avatar ebekker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

amis92 teachjing

pwsh-github-action-base's Issues

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.