end-to-end/actions/example-force-rebuild/run.sh
Earl Warren 65e3fafd02
actions: force-rebuild must use a copy of the repository
it may not have permission to write on the repository itself, nor
should it.
2025-01-12 08:06:46 +01:00

42 lines
1.1 KiB
Bash
Executable file

TMPDIR=$(mktemp -d)
trap "rm -fr $TMPDIR" EXIT
function setup_with_rebuild() {
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config-with-rebuild.yml forgejo-runner.sh reload
}
function setup_without_rebuild() {
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config-without-rebuild.yml forgejo-runner.sh reload
}
function run() {
local dir="$1"
local expected="$2"
local repo=root/example-$example
forgejo-test-helper.sh push_workflow $dir $url root example-$example setup-forgejo $token
sha=$(forgejo-test-helper.sh branch_tip $url $repo main)
forgejo-test-helper.sh wait_$expected $url $repo $sha
}
function main() {
local dir=$TMPDIR/repository
cp -a $EXAMPLE_DIR $dir
# set up passing docker action
echo "0" >$dir/.forgejo/local-docker-action/input.txt
setup_with_rebuild
run $dir success
# change docker action to fail
echo "1" >$dir/.forgejo/local-docker-action/input.txt
# ... but without a rebuild, it should still pass
setup_without_rebuild
run $dir success
# now the action should fail
setup_with_rebuild
run $dir failure
}
main