mirror of
https://github.com/nektos/act.git
synced 2026-04-26 01:15:51 +03:00
[PR #514] [MERGED] Add support for composite actions #1480
Labels
No labels
area/action
area/cli
area/docs
area/image
area/runner
area/workflow
backlog
confirmed/not-planned
kind/bug
kind/discussion
kind/external
kind/feature-request
kind/question
meta/duplicate
meta/invalid
meta/need-more-info
meta/resolved
meta/wontfix
meta/workaround
needs-work
pull-request
review/not-planned
size/M
size/XL
size/XXL
stale
stale-exempt
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/act#1480
Loading…
Add table
Add a link
Reference in a new issue
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?
📋 Pull Request Information
Original PR: https://github.com/nektos/act/pull/514
Author: @mdelillo
Created: 2/2/2021
Status: ✅ Merged
Merged: 4/2/2021
Merged by: @cplee
Base:
master← Head:composite-actions📝 Commits (10+)
31531c1Add support for composite actions2442b3eMerge branch 'master' into composite-actionsa9900d4Fix to make more complex composite actions work0a71eadMerge pull request #1 from nektos/master63c4fbaMerge branch 'master' into PLOPS-427_fix_act_composite_actionsfd3e08bFix to make more complex composite actions work2d183a3Let's validate the steps in the composite steps to fail on uses and run's without shell, like the real worldbc0012fAdd support for composite actions2652416Add workflow to test composite actions383b3b4Log instead of panicing when output is mismatched📊 Changes
11 files changed (+236 additions, -16 deletions)
View changed files
➕
.github/actions/composite/action.yml(+22 -0)➕
.github/actions/composite/script.sh(+1 -0)➕
.github/workflows/test-composite.yml(+25 -0)📝
pkg/model/action.go(+6 -1)📝
pkg/model/workflow.go(+9 -0)📝
pkg/runner/command.go(+15 -2)📝
pkg/runner/run_context.go(+28 -13)📝
pkg/runner/runner_test.go(+2 -0)📝
pkg/runner/step_context.go(+62 -0)➕
pkg/runner/testdata/uses-composite/composite_action/action.yml(+48 -0)➕
pkg/runner/testdata/uses-composite/push.yml(+18 -0)📄 Description
This is my first attempt at implementing #339. It supports most features I've tested (using this repo) including using inputs and outputs. One missing feature is using the
Defaultvalue of an input that is not provided.Before going too far I wanted to get feedback on how to implement some functionality. For convenience I put most of the logic into the
runActionmethod, but I'm sure there are better ways to organize this code.The first problem I ran into is that
${{ github.action_path }}was getting interpolated to an empty string. The quick fix was just to dostrings.ReplaceAllon theRunfield.The next problem was that outputs from the action were not available due to them being associated with the wrong step. Considering this example, the action declares an output called
random-number. But the value must be retrieved from therandom-idoutput of therandom-number-generatorstep.The hacky way I solved this was to add
OutputMappingsto theRunContextwhich is used to map outputs from action steps to outputs of the action itself. TheCurrentStepof theRunContextalso needed to be updated to the ID of the step within the action to know whether the value needs to be mapped. When the action is run, all of the outputs are parsed into this map which is later used bysetOutput.Using the above example, the random number will be stored in
rc.StepResults[foo].Outputs[random-number]instead ofrc.StepResults[foo].Outputs[random-id].🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.