summaryrefslogtreecommitdiffstats
path: root/examples/docker-compose/compose-demo-workflow.yml
blob: 2f61d4adfd075e5d39d08c885a29474559b16e3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright 2023 The Forgejo Authors.
# SPDX-License-Identifier: MIT

version: "3"

services:

  demo-workflow:
    image: alpine:3.18
    links:
      - forgejo
    depends_on:
      runner-register:
        condition: service_completed_successfully
    command: >-
      sh -xc '
      apk add --quiet git curl jq ;
      mkdir -p /srv/demo ;
      cd /srv/demo ;
      git init --initial-branch=main ;
      mkdir -p .forgejo/workflows ;
      echo "{ on: [push], jobs: { test: { runs-on: docker, steps: [ { run: echo All Good } ] } } }" > .forgejo/workflows/demo.yml ;
      git add . ;
      git config user.email root@example.com ;
      git config user.name username ;
      git commit -m 'demo' ;
      while : ; do
        git push --set-upstream --force http://root:admin1234@forgejo:3000/root/test main && break ;
        sleep 5 ;
      done ;
      sha=`git rev-parse HEAD` ;
      while : ; do
        curl -sS -f http://forgejo:3000/api/v1/repos/root/test/commits/$$sha/status | jq --raw-output .state | tee status ;
        grep success status && break ;
        sleep 5 ;
      done ;
      echo DEMO WORKFLOW SUCCESS
      '