mirror of
https://code.forgejo.org/actions/setup-forgejo
synced 2025-06-08 03:58:19 +02:00
add example of cron task
This commit is contained in:
parent
b081450249
commit
7e8c8064af
12 changed files with 102 additions and 41 deletions
14
testdata/example-cron/.forgejo/workflows/test.yml
vendored
Normal file
14
testdata/example-cron/.forgejo/workflows/test.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
on:
|
||||
schedule:
|
||||
- cron: '* * * * *'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: debian:bookworm
|
||||
options: "--volume /srv/example-cron-volume:/srv/example-cron-volume"
|
||||
|
||||
steps:
|
||||
- run: |
|
||||
touch /srv/example-cron-volume/DONE
|
7
testdata/example-cron/run.sh
vendored
Executable file
7
testdata/example-cron/run.sh
vendored
Executable file
|
@ -0,0 +1,7 @@
|
|||
forgejo-test-helper.sh push_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token)
|
||||
# cron runs once per minute, give it three minutes max before declaring failure
|
||||
if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example-cron-volume/DONE ; then
|
||||
cat $FORGEJO_RUNNER_LOGS
|
||||
false
|
||||
fi
|
||||
|
30
testdata/example-cron/runner-config.yaml
vendored
Normal file
30
testdata/example-cron/runner-config.yaml
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
log:
|
||||
level: info
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
capacity: 1
|
||||
env_file: .env
|
||||
timeout: 3h
|
||||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: []
|
||||
|
||||
cache:
|
||||
enabled: false
|
||||
dir: ""
|
||||
host: ""
|
||||
port: 0
|
||||
|
||||
container:
|
||||
network: ""
|
||||
privileged: false
|
||||
options:
|
||||
workdir_parent:
|
||||
valid_volumes: ["/srv/example-cron-volume"]
|
||||
docker_host: ""
|
||||
|
||||
host:
|
||||
workdir_parent:
|
2
testdata/example-cron/setup.sh
vendored
Executable file
2
testdata/example-cron/setup.sh
vendored
Executable file
|
@ -0,0 +1,2 @@
|
|||
mkdir /srv/example-cron-volume
|
||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
1
testdata/example-cron/teardown.sh
vendored
Executable file
1
testdata/example-cron/teardown.sh
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
forgejo-runner.sh reload
|
5
testdata/example-if-fail/expected-to-fail.sh
vendored
5
testdata/example-if-fail/expected-to-fail.sh
vendored
|
@ -1,5 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
grep --quiet 'IF TEST FAILURE' $FORGEJO_RUNNER_LOGS
|
||||
grep --quiet 'IF TEST ALWAYS' $FORGEJO_RUNNER_LOGS
|
7
testdata/example-if-fail/run.sh
vendored
Executable file
7
testdata/example-if-fail/run.sh
vendored
Executable file
|
@ -0,0 +1,7 @@
|
|||
if forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) >& /tmp/run.out ; then
|
||||
cat /tmp/run.out
|
||||
false
|
||||
fi
|
||||
|
||||
grep --quiet 'IF TEST FAILURE' $FORGEJO_RUNNER_LOGS
|
||||
grep --quiet 'IF TEST ALWAYS' $FORGEJO_RUNNER_LOGS
|
3
testdata/example-service/setup.sh
vendored
Executable file
3
testdata/example-service/setup.sh
vendored
Executable file
|
@ -0,0 +1,3 @@
|
|||
> /srv/example-service-volume-valid
|
||||
> /srv/example-service-volume-invalid
|
||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
1
testdata/example-service/teardown.sh
vendored
Executable file
1
testdata/example-service/teardown.sh
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
forgejo-runner.sh reload
|
Loading…
Add table
Add a link
Reference in a new issue