mirror of
https://github.com/fbartels/cloudron-drone-app.git
synced 2025-02-15 11:25:14 +00:00
readme and tweaks
Signed-off-by: Felix Bartels <felix@host-consultants.de>
This commit is contained in:
parent
505d264466
commit
438909a049
3 changed files with 78 additions and 15 deletions
57
README.md
57
README.md
|
@ -1,4 +1,57 @@
|
|||
# Drone CI for Cloudron
|
||||
|
||||
Run the Drone server on Cloudron and the agents locally.
|
||||
|
||||
I am using this setup together with a Gitea running on the same Cloudron installation.
|
||||
|
||||
## Requirements
|
||||
|
||||
- `docker-compose`
|
||||
- `git`
|
||||
- `make`
|
||||
- Cloudron CLI
|
||||
|
||||
## Tips and Tricks
|
||||
|
||||
I would also like to share some very useful commands. To install `drone` CLI, follow [official docs](https://docs.drone.io/cli/install/).
|
||||
|
||||
### Using drone-cli
|
||||
|
||||
Go to your [user settings](https://drone.9wd.eu/account) and get login information
|
||||
|
||||
```bash
|
||||
export DRONE_SERVER=https://drone.9wd.eu
|
||||
export DRONE_TOKEN=your token
|
||||
drone info
|
||||
```
|
||||
|
||||
### Executing pipelines directly
|
||||
|
||||
You can also run pipelines directly with the Drone CLI:
|
||||
|
||||
```bash
|
||||
drone exec --secret-file drone_secrets.yaml .drone.yml
|
||||
```
|
||||
|
||||
A template for `drone-secrets.yaml`:
|
||||
|
||||
```yaml
|
||||
slack_url: https://hooks.slack.com/services/xxxxxxxxxxxx
|
||||
```
|
||||
|
||||
### Adding secrets through CLI
|
||||
|
||||
You can either add secrets through the web UI or use drone directly from your terminal:
|
||||
|
||||
```bash
|
||||
drone secret add -repository username/repository-name --name foo --data bar --allow-pull-request
|
||||
```
|
||||
|
||||
## Inspiration
|
||||
|
||||
- [Setting up simple, self-hosted & fast CI/CD solution with Drone.io](https://webhookrelay.com/blog/2019/02/11/using-drone-for-simple-selfhosted-ci-cd/)
|
||||
|
||||
## TODO
|
||||
|
||||
- remove commited secrets
|
||||
- retrieve rpc secret from cloudron
|
||||
- [*] remove commited secrets
|
||||
- [*] retrieve rpc secret from cloudron
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
- DRONE_RPC_SERVER=https://drone.9wd.eu
|
||||
- DRONE_RPC_SECRET=QdExkSpgVY5RiC783UcqFgt8mvEs0Mid
|
||||
- DRONE_RUNNER_CAPACITY=2
|
||||
- DRONE_RUNNER_NAME="clifford"
|
||||
- DRONE_RPC_SERVER=${DRONE_RPC_SERVER}
|
||||
- DRONE_RPC_SECRET=${DRONE_RPC_SECRET}
|
||||
- DRONE_RUNNER_CAPACITY=${DRONE_RUNNER_CAPACITY}
|
||||
- DRONE_RUNNER_NAME=${DRONE_RUNNER_NAME}
|
28
run-agent.sh
28
run-agent.sh
|
@ -1,4 +1,4 @@
|
|||
#/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
|
@ -6,12 +6,22 @@ random_string() {
|
|||
LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c32
|
||||
}
|
||||
|
||||
if [ ! -e .env ]; then
|
||||
cat <<-EOF > ".env"
|
||||
DRONE_RPC_SERVER=https://drone.9wd.eu
|
||||
DRONE_RPC_SECRET=QdExkSpgVY5RiC783UcqFgt8mvEs0Mid
|
||||
DRONE_RUNNER_CAPACITY="$(nproc)"
|
||||
DRONE_RUNNER_NAME="$(hostname)"
|
||||
EOF
|
||||
fi
|
||||
update_env_file () {
|
||||
varname="$1"
|
||||
varvalue="$2"
|
||||
if ! grep -q "$varname" ./.env; then
|
||||
echo "$varname=$varvalue" >> ./.env
|
||||
else
|
||||
sed -i "/$varname/c $varname=$varvalue" ./.env
|
||||
fi
|
||||
}
|
||||
|
||||
cloudron pull /app/data/.env .env
|
||||
|
||||
. ./.env
|
||||
|
||||
update_env_file DRONE_RPC_SERVER "https://$DRONE_SERVER_HOST"
|
||||
update_env_file DRONE_RUNNER_CAPACITY "$(nproc)"
|
||||
update_env_file DRONE_RUNNER_NAME "$(hostname)"
|
||||
|
||||
docker-compose up -d
|
Loading…
Reference in a new issue