Using Docker Run inside of Gitea Actions #189
Labels
No Label
kind
bug
kind
build
kind/compatible
kind
dependencies
kind
docs
kind
enhancement
kind
feature
kind
help wanted
kind
proposal
kind
refactor
related
act
related
environment
related
exec
related
gitea
related
workflow
reviewed
confirmed
reviewed
duplicate
reviewed
invalid
reviewed
needs feedback
reviewed
wontfix
reviewed
workaround
No Milestone
No Assignees
8 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: gitea/act_runner#189
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Previously, I used drone and woodpecker to collaborate with Gitea for CI/CD. Now, I'm trying to replace it with Gitea Actions.My Actions steps require some pre-environment installations, such as specific versions of
.NET Core
andNode.js
, etc. Of course, these installations can be implemented with actions likestep-dotnet
,step-nodejs
, etc. However, thesesetup-xxx
actions are already very slow in themselves, especially in the Chinese network environment. Therefore, we prefer to use Docker containers with pre-installed environment as the Step execution environment.I found an action on GitHub called docker-run-action that met my needs. It allows you to specify an image, options and a list of commands to run during the build process.
It works normally in Github Actions, but there are some issues in Gitea Actions.
Test found that the container can start normally in this
docker-run-action
, but the mount specified inoptions: -v ${{ github.workspace }}:/var/www
did not appear in the container, so it was impossible to run the command afterrun
.I think this may be an issue caused by some mechanism of act_runner. Can you check and fix it? It would be a great help for users like us.
If you want to specify the image of enviornment, there are two ways:
you can specify labels when register runner, like this:
then specify what kind of runner will execute the action in workflow file:
@sillyguodong Sorry, you misunderstood or I may not have expressed it clearly. The scenario I was referring to is not the running environment of act_run jobs, but the running environment of a specific step.
Oh I see, sorry for misunderstood.
The first thing to clarify is that there is a difference between
Github Actions
andGitea Actions
. TheGitahub Actions
run jobs directly on the runner machine by default (unless using jobs.job-id.contianer to specify contianer). AndGitea Actions
run jobs on containers by default, it depends on the labels that you defined when regiteringact_runner
.As mentioned above, Due to
Gitea Actions
run jobs on containers by default, so${{github.workspace}}
is actually a directory within the container. But the flag of-v
should mount a host directory into the container directory. So there should be an error.And
Github Actions
run jobs directly on the host, so it works well.Gitea Actions
also can run jobs directly on the host. I suggest you refer to the document, add a host label to the runner, and re-register it.Thank you for your reply. However, I believe that solving this problem can bring at least two benefits:
drone
orwoodpecker
can easily switch toGitea Actions
.setup-xxx
.So, if possible, I hope you can fix this problem and allow a container to mount a directory in another container.
Maybe --volumes-from will meet your needs.
And it works.
But I think there are some issues of the action(
docker-run-action
) that need to be fixed:I think running specific steps in specific containers is something that goes against the principles of actions. I see it as a huge benefit over woodpecker/drone that actions is designed to run everything in one shared environment as it makes use cases that rely on state outside the working directory possible.
There is no per-step isolation like in woodpecker/drone, so all steps run in the same environment, which simplifies a lot of tasks that were previously hard do to with isolated steps where global state like GOCACHE or npm cache would be lost between steps.
So I suggest we close this. If you want different images per step and per-step isolation, woodpecker/drone are better suited for that.
Not all steps, docker actions get their own container
The goal is to simplify some building steps, but not all can be done in one step. For more information, please refer to this blog post:
https://aschmelyun.com/blog/using-docker-run-inside-of-github-actions/
@qihangnet can you try that?
Hello, I am using this solution as well, thanks for documenting it!
Now I am wondering, how did you find this
env
variable ? I am unable to find any reference, e.g. to other available/built-in variables.Thank you
jobs:
build:
strategy:
matrix:
build_type: [ "Debug", "Release" ]
runs-on: ubuntu-20.04
env:
BUILD_DIR: build
steps:
- name: show-envs
run: |
env | sort
try this
I too would like this ability to run particular steps inside containers; I tried the above action as well as
kohlerdominik/docker-run-action@v1.1.0
but was seeing similar issues with container cleanup due to in-use volume:I found that a cleanup step after the
docker-run-action
step seemed to resolve the error at the end of the workflow. Here's an excerpt of thedocker-run-action
and cleanup steps:The docker cleanup step gets the id of the latest container ID (which would be the one created via the
docker-run-action
) and removes it, which frees up the volume when the overall workflow exits.Better still, add
--rm
to the options and the Docker cleanup step isn't needed.I can report that after reading this issue I was able to get started successfully. Much appreciated.
Example of how I use the tips found here: