2024-04-07 09:53:48 -05:00
|
|
|
# Copyright 2024 The Forgejo Authors.
|
2023-08-24 05:28:17 -05:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
|
|
demo-workflow:
|
2024-08-13 01:37:52 -05:00
|
|
|
image: code.forgejo.org/oci/alpine:3.19
|
2023-08-24 05:28:17 -05:00
|
|
|
links:
|
|
|
|
- forgejo
|
|
|
|
command: >-
|
2023-10-06 09:19:55 -05:00
|
|
|
sh -ec '
|
2023-08-24 05:28:17 -05:00
|
|
|
apk add --quiet git curl jq ;
|
|
|
|
mkdir -p /srv/demo ;
|
|
|
|
cd /srv/demo ;
|
|
|
|
git init --initial-branch=main ;
|
|
|
|
mkdir -p .forgejo/workflows ;
|
2023-10-06 09:18:09 -05:00
|
|
|
echo "{ on: [push], jobs: { test: { runs-on: docker, steps: [ {uses: actions/checkout@v4}, { run: echo All Good } ] } } }" > .forgejo/workflows/demo.yml ;
|
2024-04-07 11:07:00 -05:00
|
|
|
echo "{ on: [push], jobs: { test_docker: { runs-on: ubuntu-22.04, steps: [ { run: docker info } ] } } }" > .forgejo/workflows/demo_docker.yml ;
|
2023-08-24 05:28:17 -05:00
|
|
|
git add . ;
|
|
|
|
git config user.email root@example.com ;
|
|
|
|
git config user.name username ;
|
2023-11-07 13:19:08 -06:00
|
|
|
git commit -m demo ;
|
2023-08-24 05:28:17 -05:00
|
|
|
while : ; do
|
2023-09-04 11:19:15 -05:00
|
|
|
git push --set-upstream --force http://root:{ROOT_PASSWORD}@forgejo:3000/root/test main && break ;
|
2023-08-24 05:28:17 -05:00
|
|
|
sleep 5 ;
|
|
|
|
done ;
|
|
|
|
sha=`git rev-parse HEAD` ;
|
2023-11-07 13:19:08 -06:00
|
|
|
for delay in 1 1 1 1 2 5 5 10 10 10 15 30 30 30 30 30 30 30 ; do
|
2023-08-24 05:28:17 -05:00
|
|
|
curl -sS -f http://forgejo:3000/api/v1/repos/root/test/commits/$$sha/status | jq --raw-output .state | tee status ;
|
2023-10-06 09:19:55 -05:00
|
|
|
if grep success status ; then echo DEMO WORKFLOW SUCCESS && break ; fi ;
|
|
|
|
if grep failure status ; then echo DEMO WORKFLOW FAILURE && break ; fi ;
|
|
|
|
sleep $$delay ;
|
2023-11-07 13:19:08 -06:00
|
|
|
done ;
|
|
|
|
grep success status || echo DEMO WORKFLOW FAILURE
|
2023-08-24 05:28:17 -05:00
|
|
|
'
|