Replies: 5 comments 5 replies
-
Thanks for the feedback - you're right that at the moment we resolve actions before we expand any of these. It's something that we can explore in the future. One thing jumps out at me though - and it's possible that this is just an oversimplification of the problem to reproducible steps (which I appreciate!) but I wanted to mention it if not: matrix-var-in-uses-docker-tag:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
img:
- bullseye-slim
- buster-slim
steps:
- uses: docker://debian:${{ matrix.img }} is not a thing that one would really do, idiomatically. You're using the If the goal is to run a command inside a container, then that should be done using a container-based job. (And you can use matrix elements to specify that container.) This: matrix-var-in-uses-docker-tag:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
img:
- bullseye-slim
- buster-slim
container: debian:${{ matrix.img }}
steps:
- run: echo Hello, world. would be the preferred mechanism. |
Beta Was this translation helpful? Give feedback.
-
You might be able to cheat by defining a local composite These days, a composite action can |
Beta Was this translation helpful? Give feedback.
-
I return to this issue every few months (working on a couple of years!). We're trying to build out a reusable set of steps and workflows in Github Actions, and one of the stumbling blocks is that composite actions can't reasonably refer to "library" actions in the shared actions repository. That is, specifically, we have a service repo
I think that relative Reviewing the There is an existing PR on |
Beta Was this translation helpful? Give feedback.
-
Hi, It is like GitHub developers do not use GitHub actions for their development so they do not experience the difficulties of their own technology or the scale is very small... Re-usability is a fundamental concern in engineering. Until properly resolved, a temporary (hack?) solution for an CI action library is possible. Provided a repository name: 'a1'
description: 'a1'
runs:
using: "composite"
steps:
- shell: sh
run: |
action_path="${{ github.action_path }}"
if [ "${action_path#${{ github.workspace }}}" = "${action_path}" ]; then
ln -sfn "${{ github.action_path }}/.." ci-library1
fi
- uses: ./ci-library1/a2 Regards, |
Beta Was this translation helpful? Give feedback.
-
As a work around to test an github action I used the following code: runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "prepare action"
##################################################################
# This is a workaround for the fact that the action.yml file
# does not support templating. We replace the image with the
# Dockerfile, so that we can use the Dockerfile from the current
# branch.
##################################################################
run: "sed -i 's/^ image:.*$/ image: \"Dockerfile\"/g' action.yml"
- name: "Run action"
uses: "./" The released action will use an image while the current pipeline will use a docker file, containing the current version of the code. We use this to do a smoke test on the action. |
Beta Was this translation helpful? Give feedback.
-
It is currently not possible to use variables from the matrix (in a regular workflow), or inputs (in a Composite Action) to define the Actions to be used in steps of type
uses
. The workflow won't start because of a parser/syntax issues:the 'uses' attribute must be a path, a Docker image, or owner/repo@ref
.See https://github.com/hdl/containers/blob/GHA-MWEs/.github/workflows/MWE-1479.yml and https://github.com/hdl/containers/blob/GHA-MWEs/utils/mwe-input-var-in-uses/action.yml:
Additional information
The inability to use Composite Action inputs in steps of type
uses: docker://
is particularly uncomfortable, because it forces using the docker CLI explicitly. Therefore, environment variables and binds need to be manually and explicitly described. See, for instance, the following workaround to the Composite Action above: https://github.com/VUnit/vunit_action/blob/master/action.yml.Being able to use the context would be a suitable solution to using a local action without explicitly checking out the repository, as discussed in actions/runner#646 (comment). Precisely,
uses: ${{ github.repository }}/.github/myaction@${{ github.ref_name }}
would be equivalent to:Refs:
Beta Was this translation helpful? Give feedback.
All reactions