Skip to content

Instantly share code, notes, and snippets.

@TylerLeonhardt
Last active July 2, 2020 17:01
Show Gist options
  • Save TylerLeonhardt/b39019d84def552a571df356aa084a43 to your computer and use it in GitHub Desktop.
Save TylerLeonhardt/b39019d84def552a571df356aa084a43 to your computer and use it in GitHub Desktop.
Creating a Docker Action (PowerShell Edition)

Creating a Docker Action (PowerShell Edition)

The container-action-pwsh repo contains the base files to create a Docker action that uses PowerShell.

Create a Repo from the Template

Navigate to https://github.com/TylerLeonhardt/container-action-pwsh

Click on Use this template to create the repo for your action.

template

Complete creating your repo and clone the repo.

NOTE: The location of the repo will be how users will reference your action in their workflow file with the using keyword.

e.g. To use https://github.com/actions/setup-node, users will author:

steps:
    using: actions/setup-node@master

Define Metadata

Your action has a name and a description. Update the author.

Create inputs that your unit of work will need. These will be what workflow authors set with the with: keyword.

name: 'My Container Action'
description: 'Get started with Container actions'
author: 'GitHub'
inputs: 
  myInput:
    description: 'Input to use'
    default: 'world'
runs:
  using: 'docker'
  image: 'Dockerfile'
  args:
    - ${{ inputs.myInput }}

It will be run with docker and the input is mapped into the $args

Change Code

The entry point is in entrypoint.ps1

Write-Host "Hello $args!"

Publish

Simply push your action to publish.

$ git push

The runner will download the action and build the docker container on the fly at runtime.

Consider versioning your actions with tags. See versioning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment