Skip to content

run specified steps outside of container before the container is launched #812

@igagis

Description

@igagis

Let's consider the following workflow:

name: ci
on: [push, pull_request]
jobs:
  linux:
    runs-on: ubuntu-latest
    container: debian:buster
    steps:
      - name: git clone
        uses: actions/checkout@main
      - name: build
        run: make

for job linux it will first launch the container, then checkout the source code (inside of the already running container?), then run the build step inside of the container.

What I want to be able to do is to add some pre-steps which would be run outside of the container and before the container is launched. In particular, I need this to install qemu and binfmt packages.
So, the workflow would look something like this:

name: ci
on: [push, pull_request]
jobs:
  linux:
    runs-on: ubuntu-latest
    container: igagis/my_image:arm
    pre-steps:
      - name: install qemu and binfmt
        run: apt update && apt install --yes binfmt-support qemu-user-static
    steps:
      - name: git clone
        uses: actions/checkout@main
      - name: build
        run: make

Note, that I changed the container image to my custom built image for ARM architecture, i.e. all binaries inside of the image are ARM binaries.
After installing qemu and binfmt it is possible to run ARM binaries on x86_64 architecture, using emulation. This approach works for me on Travis-CI, but there I start the docker manually and, thus, I have full control over what I run in host environment and what inside of the container. Now I'm trying to move to github actions and have this problem that it is only possible to either run everything inside of the container or everything in host ubuntu virtual machine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions