Use Drone plugins in Gitea Actions

Convert your existing Drone workflow to work with Gitea Actions.

Drone.IO is a CI/CD platform that uses Docker Containers for each pipeline step. This makes it easy to use existing Docker containers as steps in your pipeline. You can go futher and create special containers that are designed to be used as steps in your pipeline that accept arguments from the pipeline to run pre-defined tasks.

These plugins can be re-used in Gitea Actions to be able to run the same tasks in Gitea Actions as you would in Drone.

To give an example, a Drone plugin I used was drone-scp, and what it does is to allow me to copy files from the build pipeline to a remote server. I had a step in my Drone pipeline that looked like this:

- name: scp files
  image: appleboy/drone-scp
  settings:
    host: example1.com
    username: ubuntu
    password:
      from_secret: ssh_password
    target: /home/deploy/web
    source:
      - release/*.tar.gz

The workflow step will call a pre-defined binary in the drone-scp Docker image that will copy the files from the release directory to the target directory on the remote server without the need to have that script defined in full in the pipeline.

As this is published as a Docker image, it can be used in Gitea Actions as well. There are two approaches: a quick approach that works for most plugins, and a more involved approach that wraps the plugin as a full Gitea Action.

The simple approach: use the Docker image directly#

The easiest way to use a Drone plugin in Gitea Actions is to reference the Docker image directly with uses: docker:// and pass the plugin's expected PLUGIN_ environment variables via the step's env: block:

name: copy files
on: [push]
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: docker://appleboy/drone-scp
      env:
        PLUGIN_HOST: ${{ secrets.HOST }}
        PLUGIN_USERNAME: ubuntu
        PLUGIN_PASSWORD: ${{ secrets.SSH_PASSWORD }}
        PLUGIN_TARGET: /home/deploy/web
        PLUGIN_SOURCE: release/*.tar.gz

This works because Drone plugins read their configuration from PLUGIN_-prefixed environment variables (derived from the settings: block in Drone), and step-level env: variables in Gitea Actions are passed directly into Docker containers. No repackaging is needed.

The full approach: wrap the plugin as a Gitea Action#

If you want to publish a reusable Action with defined inputs (so consumers use with: instead of env:), you can wrap the Drone plugin in a Dockerfile, entrypoint script, and action.yml. The Dockerfile should look something like this:

FROM appleboy/drone-scp

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

The entrypoint will be a short script that passes all the input arguments for the action to the drone-scp binary. The entrypoint.sh script should look something like this:

#!/bin/sh

set -eu

sh -c "/bin/drone-scp $*"

Note: When using the with: block in Gitea Actions (like GitHub Actions), inputs are passed to Docker containers as environment variables prefixed with INPUT_ (e.g. INPUT_HOST). Drone plugins natively expect the PLUGIN_ prefix (e.g. PLUGIN_HOST). Many popular Drone plugin authors (including Appleboy) have updated their binaries to accept both prefixes. If a plugin does not recognise INPUT_ variables, you may need to translate them in the entrypoint script by mapping each INPUT_* variable to its corresponding PLUGIN_* variable.

Finally, you'll need an action.yml file that lets Gitea Actions know what inputs should be used.

name: 'drone-scp Gitea Action'
# This tells the Gitea Action runner what type of Action this is
# in this case, it's "docker", and the image to use is the Dockerfile
runs:
  using: 'docker'
  image: 'Dockerfile'
inputs:
  host:
    description: 'scp remote host'
# ... define all the remaining inputs that exist for the Drone Plugin

Now, you can reference this action in any Gitea Actions workflow the same way that you would have used the Drone.IO plugin.

An example of this in action:

name: copy files
on: [push]
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: https://gitea.com/techknowlogick/scp-gitea-action@main
      with:
        host: ${{ secrets.HOST }}
...

The author of the SCP Drone plugin, Appleboy, has done exactly this already, and you can use that action from his repo found at https://github.com/appleboy/scp-action/

This is a simple example, but you can convert any Drone plugin to a Gitea Action by following the same steps. This allows you to re-use existing plugins in Gitea Actions without having to re-write the entire plugin, which is especially useful as you can use the programming language of your choice, rather than relying on the ones supported by the runner natively.