do not try to replace SELF if there are not workflows

This commit is contained in:
Earl Warren 2023-03-29 16:50:46 +02:00
parent 5e74823706
commit ed3687d21a
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 14 additions and 7 deletions

View file

@ -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:

View file

@ -48,7 +48,11 @@ function push() {
local dir="$DIR/$project"
rsync -a $directory/ $dir/
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