2023-08-24 13:28:17 +03:00
|
|
|
# SPDX-License-Identifier: MIT
|
2023-10-06 13:14:13 +03:00
|
|
|
on:
|
|
|
|
push:
|
2023-10-15 19:07:57 +03:00
|
|
|
branches:
|
|
|
|
- 'main'
|
2023-11-07 22:19:08 +03:00
|
|
|
pull_request:
|
2023-08-24 13:28:17 +03:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
example-docker-compose:
|
|
|
|
runs-on: self-hosted
|
|
|
|
steps:
|
2023-12-04 23:28:37 +03:00
|
|
|
- uses: actions/checkout@v4
|
2023-08-24 13:28:17 +03:00
|
|
|
|
|
|
|
- name: Install docker
|
|
|
|
run: |
|
|
|
|
apt-get update -qq
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
apt-get install -qq -y ca-certificates curl gnupg
|
|
|
|
install -m 0755 -d /etc/apt/keyrings
|
|
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
|
|
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
|
|
apt-get update -qq
|
2024-11-12 13:52:18 +03:00
|
|
|
apt-get install -qq -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
2023-08-24 13:28:17 +03:00
|
|
|
docker version
|
|
|
|
docker compose version
|
|
|
|
|
|
|
|
- name: run the example
|
|
|
|
run: |
|
|
|
|
set -x
|
|
|
|
cd examples/docker-compose
|
2023-09-04 19:19:15 +03:00
|
|
|
secret=$(openssl rand -hex 20)
|
|
|
|
sed -i -e "s/{SHARED_SECRET}/$secret/" compose-forgejo-and-runner.yml
|
2024-04-07 18:04:38 +03:00
|
|
|
cli="docker compose --progress quiet -f compose-forgejo-and-runner.yml"
|
2023-08-24 13:28:17 +03:00
|
|
|
#
|
2024-04-07 18:04:38 +03:00
|
|
|
# Launch Forgejo & the runner
|
2023-08-24 13:28:17 +03:00
|
|
|
#
|
|
|
|
$cli up -d
|
2024-04-07 18:04:38 +03:00
|
|
|
for delay in $(seq 60) ; do test -f /srv/runner-data/.runner && break ; sleep 30 ; done
|
|
|
|
test -f /srv/runner-data/.runner
|
|
|
|
#
|
|
|
|
# Run the demo workflow
|
|
|
|
#
|
|
|
|
cli="$cli -f compose-demo-workflow.yml"
|
|
|
|
$cli up -d demo-workflow
|
2023-08-24 13:28:17 +03:00
|
|
|
#
|
|
|
|
# Wait for the demo workflow to complete
|
|
|
|
#
|
|
|
|
success='DEMO WORKFLOW SUCCESS'
|
2023-10-06 17:19:55 +03:00
|
|
|
failure='DEMO WORKFLOW FAILURE'
|
2023-08-24 13:28:17 +03:00
|
|
|
for delay in $(seq 60) ; do
|
2023-11-07 22:19:08 +03:00
|
|
|
$cli logs demo-workflow > /tmp/out
|
2023-08-24 13:28:17 +03:00
|
|
|
grep --quiet "$success" /tmp/out && break
|
2023-10-06 17:19:55 +03:00
|
|
|
grep --quiet "$failure" /tmp/out && break
|
2023-08-24 13:28:17 +03:00
|
|
|
$cli ps --all
|
2024-04-07 18:05:55 +03:00
|
|
|
$cli logs --tail=20 runner-daemon demo-workflow
|
|
|
|
sleep 30
|
2023-08-24 13:28:17 +03:00
|
|
|
done
|
2023-11-07 22:19:08 +03:00
|
|
|
grep --quiet "$success" /tmp/out
|
2024-04-07 21:44:41 +03:00
|
|
|
$cli logs runner-daemon > /tmp/runner.log
|
2024-08-13 09:37:52 +03:00
|
|
|
grep --quiet 'Start image=code.forgejo.org/oci/node:20-bookworm' /tmp/runner.log
|
2023-11-07 22:19:08 +03:00
|
|
|
|
2024-04-07 18:05:55 +03:00
|
|
|
- name: full docker compose logs
|
2023-11-07 22:19:08 +03:00
|
|
|
if: always()
|
|
|
|
run: |
|
|
|
|
cd examples/docker-compose
|
|
|
|
docker compose -f compose-forgejo-and-runner.yml -f compose-demo-workflow.yml logs
|