actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.89k stars 959 forks source link

Do not build container actions ahead of time #814

Open umarcor opened 3 years ago

umarcor commented 3 years ago
jobs:

  job:
    runs-on: ubuntu-latest
    steps:

    # BUG: GitHub's runner tries to build the last action before starting the first step.
    # It fails, because container image image_name does not exist yet.

    - name: Build hdlc/doc
      run: |
        docker build -t image_name - <<-EOF
        FROM asciidoctor/docker-asciidoctor
        RUN apk add -U --no-cache graphviz
        EOF

    - uses: actions/checkout@v2

    - uses: docker://image_name
      with:
        args: doc/make.sh

As a result, it is currently not possible to use local containers using the uses: docker:// syntax.

The alternative is to call docker explicitly, which requires handling all the environment manually (if necessary):

jobs:

  job:
    runs-on: ubuntu-latest
    steps:

    - name: Build hdlc/doc
      run: |
        docker build -t image_name - <<-EOF
        FROM asciidoctor/docker-asciidoctor
        RUN apk add -U --no-cache graphviz
        EOF

    - uses: actions/checkout@v2

    - name: Build site
      run: docker run -v /$(pwd)://documents/ image_name ./doc/make.sh

Using local docker images in container steps should be supported too.

umarcor commented 2 years ago

/cc @thboop, per https://github.com/actions/runner/issues/646#issuecomment-901336347

This issue applies to composite actions as well. Find a reproducer in https://github.com/hdl/containers/blob/GHA-MWEs/utils/mwe-local-container-image/action.yml and https://github.com/hdl/containers/blob/GHA-MWEs/.github/workflows/MWE-814.yml. That workflow contains the two jobs in the code blocks above, plus a job using a composite action. Example execution: https://github.com/hdl/containers/actions/runs/1451481784

umarcor commented 2 years ago

Ref: github/feedback#9053

nikola-jokic commented 2 years ago

Hi @umarcor,

We pre-fetch stuff related to the uses directive, but I will label this as an enhancement and it will be considered for a change in the future. It is also on our backlog and we will update you on the progress when we pick it up :relaxed: