Replace docker with podman
This commit is contained in:
Mikko Partio 2023-10-20 08:44:11 +03:00
parent 3e77f186b7
commit 3144022b95
7 changed files with 38 additions and 116 deletions

View File

@ -1,72 +0,0 @@
name: Docker Run Action Tests
on:
push:
branches:
- main
pull_request:
jobs:
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run docker action and set output for testing
uses: ./
id: run-docker
with:
image: docker:20.10.3
run: |
echo "::set-output name=docker-version::`echo $DOCKER_VERSION`"
- name: Test the output
uses: actions/github-script@v3
with:
script: |
const dockerVersion = '${{ steps.run-docker.outputs.docker-version }}';
if (dockerVersion !== '20.10.3') {
core.setFailed(`Smoke Test Failed`);
}
volume-mount-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create File to be mounted
run: echo "some text" > someFile
- name: Run docker action with mounted workspace
uses: ./
id: run-docker
with:
image: docker
options: -v ${{ github.workspace }}:/work
run: |
echo "::set-output name=file-contents::`cat /work/someFile`"
- name: Check if file contents match
uses: actions/github-script@v3
with:
script: |
const fileContents = '${{ steps.run-docker.outputs.file-contents }}';
if (fileContents !== 'some text') {
core.setFailed(`Unable to mount workspace volume`);
}
container-network-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: test
POSTGRES_USER: test
POSTGRES_DB: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10
steps:
- uses: actions/checkout@v2
- name: Run docker action and test network connection
uses: ./
with:
image: postgres
run: >
pg_isready -d test -U test -h postgres -p ${{ job.services.postgres.ports[5432] }}
options: >
-e PGPASSWORD=test

View File

@ -1,7 +0,0 @@
FROM docker:20.10
RUN apk add bash
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 Abdud Dayan Adeeb
Copyright (c) 2023 Finnish Meteorological Institute
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,8 +1,9 @@
# Docker Run Action
# Podman Run Action
- run a specific step in docker.
- forked from https://github.com/addnab/docker-run-action
- run a specific step in podman.
- run an image built by a previous step.
- See https://github.com/addnab/docker-run-action/blob/main/action.yml for all the available inputs.
- See https://github.com/fmidev/podman-run-action/blob/main/action.yml for all the available inputs.
## Examples
@ -11,10 +12,10 @@
```yaml
- name: Checkout
uses: actions/checkout@v2 # Required to mount the Github Workspace to a volume
- uses: addnab/docker-run-action@v3
- uses: fmidev/podman-run-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ secrets.PODMAN_USERNAME }}
password: ${{ secrets.PODMAN_PASSWORD }}
registry: gcr.io
image: private-image:latest
options: -v ${{ github.workspace }}:/work -e ABC=123
@ -25,10 +26,10 @@
#### run a privately-owned image
```yaml
- uses: addnab/docker-run-action@v3
- uses: fmidev/podman-run-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ secrets.PODMAN_USERNAME }}
password: ${{ secrets.PODMAN_PASSWORD }}
registry: gcr.io
image: test-image:latest
run: echo "hello world"
@ -36,11 +37,11 @@
#### run an image built by a previous step
```yaml
- uses: docker/build-push-action@v2
- uses: podman/build-push-action@v2
with:
tags: test-image:latest
push: false
- uses: addnab/docker-run-action@v3
- uses: fmidev/podman-run-action@v1
with:
image: test-image:latest
run: echo "hello world"
@ -50,9 +51,9 @@
#### use a specific shell (default: sh).
*Note: The shell must be installed in the container*
```yaml
- uses: addnab/docker-run-action@v3
- uses: fmidev/podman-run-action@v1
with:
image: docker:latest
image: podman:latest
shell: bash
run: |
echo "first line"

View File

@ -1,14 +0,0 @@
# addnab/docker-run-action Releases
### 3.0.0
- Upgrade to docker 20.10 https://github.com/addnab/docker-run-action/pull/12
### 2.0.0
- Added support for networking with other containers [#3](https://github.com/addnab/docker-run-action/pull/3) [#7](https://github.com/addnab/docker-run-action/pull/7)
- Added tests [#7](https://github.com/addnab/docker-run-action/pull/7)
### 1.0.0
- Initial release

View File

@ -1,5 +1,5 @@
# action.yml
name: 'Docker Run Action'
name: 'Podman Run Action'
description: 'Run a command in a new container'
inputs:
image:
@ -24,10 +24,24 @@ inputs:
password:
description: 'Password'
required: false
docker_network:
description: 'Docker Network ID'
podman_network:
description: 'Podman Network ID'
default: ${{ job.container.network }}
required: false
runs:
using: 'docker'
image: 'Dockerfile'
using: 'composite'
steps:
- name: Set environment
run: |
echo "INPUT_USERNAME=${{ inputs.username }}" >> "$GITHUB_ENV"
echo "INPUT_PASSWORD=${{ inputs.password }}" >> "$GITHUB_ENV"
echo "INPUT_IMAGE=${{ inputs.image }}" >> "$GITHUB_ENV"
echo "INPUT_PODMAN_NETWORK=${{ inputs.podman_network }}" >> "$GITHUB_ENV"
echo "INPUT_RUN=${{ inputs.run }}" >> "$GITHUB_ENV"
echo "INPUT_SHELL=${{ inputs.shell }}" >> "$GITHUB_ENV"
echo "INPUT_REGISTRY=${{ inputs.registry }}" >> "$GITHUB_ENV"
echo "INPUT_OPTIONS=${{ inputs.options }}" >> "$GITHUB_ENV"
shell: bash
- run: bash ${GITHUB_ACTION_PATH}/entrypoint.sh
shell: bash

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash
if [ ! -z $INPUT_USERNAME ];
then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin
then echo $INPUT_PASSWORD | podman login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin
fi
if [ ! -z $INPUT_DOCKER_NETWORK ];
then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK"
if [ ! -z $INPUT_PODMAN_NETWORK ];
then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_PODMAN_NETWORK"
fi
exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "${INPUT_RUN//$'\n'/;}"
exec podman run $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "${INPUT_RUN//$'\n'/;}"