Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
terminal

GitHub Action

Docker Run Step

v1.0.0

Docker Run Step

terminal

Docker Run Step

Run a step in a (private) container

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Docker Run Step

uses: kohlerdominik/[email protected]

Learn more about this action in kohlerdominik/docker-run-action

Choose a version

About

Run a step in a (private) container.

  • Use any public or private image, or one that you just built.
  • Highly customizable with descriptive inputs.
  • Copies native step behavior 1:1

Examples

Simple step wrapped in a container

- uses: kohlerdominik/docker-run-action
  with:
    image: alpine:latest
    run: |
      echo "hello world"
      uname -a

Run a step in a private image

- uses: docker/login-action@v1
  with:
    registry: ghcr.io
    username: ${{ secrets.MY_USERNAME }}
    password: ${{ secrets.MY_PASSWORD }}
- uses: kohlerdominik/docker-run-action
  with:
    image: ghcr.io/${{ github.repository }}/private-image:latest
    volumes: ${{ github.workspace }}:/workspace
    run: |
      echo "Running tests in target environment..."
      ./run-platform-tests.sh

See also Docker Login Action

Run an image built by a previous step:

- uses: docker/build-push-action@v2
  with:
    tags: application:latest
    push: false
- uses: kohlerdominik/docker-run-action
  with:
    image: application:latest
    run: ./verify-data.sh

See alo Docker Push Action

Customize the action

- uses: kohlerdominik/docker-run-action
  with:
   # public, private or local image
    image: ubuntu:latest
   # change shell (default: sh)
    shell: /bin/bash
   # change workdir (default directory for the shell)
    workdir: /workspace
   # pass or create environment variables
    env: |
      GITHUB_REF
      PREVIOUS_RESULT=${{ steps.step-id.outputs.result }}
      DB_USER=root
   # mount folders and files or create a reusable volumes
    volumes: |
      ${{ github.workspace }}/dist:/var/www
      ${{ github.workspace }}/conf/ip.conf:/etc/ip.conf
      db:/var/www/database
   # use other docker run options
    options: |
      --name=webserver
      --network test-network
   # and run a couple of instruction
    run: |
      apt-get update
      apt-get install curl
      curl icanhazip.com > /etc/ip.conf

Multiline is available for env, volumes, options and run inputs, but it's optional. If you have to pass only one argument, or want to chain all arguments on one line, it will work, too.

Contributions

Contributions are very welcome. All functionality is covered with a test, so if you add functionality, please also add a test.

First steps

  • Fork and clone this repository.
  • Have or install a reasonably modern version of node.
  • Install the dependencies:
    npm install
  • Make some changes.
  • Build the Typescript:
    npm run build && npm run package
    # run prettier:
    npm run format
    # run lint
    npm run lint
    # or do all at once
    npm run all
  • Push your changes.
  • If you're ready, create a Pull Request.