From ed3687d21a50c933f35692f20d66d06f47c6876e Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 29 Mar 2023 16:50:46 +0200 Subject: [PATCH] do not try to replace SELF if there are not workflows --- action.yml | 15 +++++++++------ forgejo-test-helper.sh | 6 +++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index dd3b7cd..48da173 100644 --- a/action.yml +++ b/action.yml @@ -5,21 +5,24 @@ description: | The forgejo-test-helper.sh script is available to help test and debug actions. - forgejo=http://root:admin1234@${{ steps.forgejo.outputs.host-port }} + `forgejo=http://root:admin1234@${{ steps.forgejo.outputs.host-port }}` - * forgejo-test-helper.sh push_self_action $forgejo root myaction vTest + * `forgejo-test-helper.sh push_self_action $forgejo root myaction vTest` Creates the repository `$forgejo/root/myaction` and populate it with the content of the repository under test, except for the `.forgejo` directory (it would otherwise create an infinite recursion loop). The tag `vTest` is set to the SHA under test. - * forgejo-test-helper.sh run_workflow testrepo $forgejo root testrepo myaction + * `forgejo-test-helper.sh run_workflow testrepo $forgejo root testrepo myaction` Create the repository `$forgejo/root/testrepo` and populate it with the content of the `testrepo` directory. All occurrences of `SELF` in `testrepo/.forgejo/workflows/*.yml` are replaced with `$forgejo/root/myaction`. + * `forgejo-test-helper.sh push testrepo $forgejo root testrepo` + Create the repository `$forgejo/root/testrepo` and populate it with the + content of the `testrepo` directory. - This combination allows to run Forgejo Actions workflows from - `testrepo` that use the action under test (`myaction`) to verify it - works as intended. + The combination of `push_self_action` and `run_workflow` allows to + run Forgejo Actions workflows from `testrepo` that use the action + under test (`myaction`) to verify it works as intended. inputs: image: diff --git a/forgejo-test-helper.sh b/forgejo-test-helper.sh index d45817e..3a3d884 100755 --- a/forgejo-test-helper.sh +++ b/forgejo-test-helper.sh @@ -48,7 +48,11 @@ function push() { local dir="$DIR/$project" rsync -a $directory/ $dir/ - sed -i -e "s|SELF|$url/$owner/$self_action|" $dir/.forgejo/workflows/*.yml + + local workflows=$dir/.forgejo/workflows/*.yml + if test "$(echo $workflows)" != "$workflows"; then + sed -i -e "s|SELF|$url/$owner/$self_action|" $dir/.forgejo/workflows/*.yml + fi ( cd $dir git init