Docker Run

docker-run

Inspiration from https://github.com/addnab/docker-run-action/releases/tag/v3, converted to a composite action. Run a docker image pulled from a repository or built by a previous step, allowing options and arguments to be set for the docker run command. See action.yml for available inputs.

Pull and run an image

- name: Checkout
  uses: actions/checkout@v3 # Required to mount the Github Workspace to a volume
- uses: GenapsysInc/internal-actions/reusable-actions/docker-run@main
  with:
    username: ${{ github.repository_owner }}
    password: ${{ secrets.GHCR_TOKEN }}
    registry: ghcr.io
    image: ghcr.io/genapsysinc/private-image:latest
    options: -v ${{ github.workspace }}:/workspace -e ENV_VAR="env_var"
    args: --arg-1 value_1 --arg-2 value_2

This would roughly translate to:

echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
docker run -v ${{ github.workspace }}:/workspace -e ENV_VAR="env_var" ghcr.io/genapsysinc/private-image:latest --arg-1 value_1 --arg-2 value_2

Run an image built by a previous step

- uses: GenapsysInc/internal-actions/reusable-actions/docker-build-push@main
  with:
    context: .
    dockerfile: path/to/Dockerfile
    tags: test-image:latest
    load: true
- uses: GenapsysInc/internal-actions/reusable-actions/docker-run@main
  with:
    image: test-image:latest