aboutsummaryrefslogtreecommitdiff
path: root/home/bin/drone-encsecrets
blob: b34109416629f94f865f8e95d0271200331ca203 (plain) (blame)
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
#!/bin/bash

# Update drone-ci secrets

# Get the repository of the current git project.
# The repository name is the username/project tuple of the origin remote.
REPO=${REPO:-$(git remote show origin -n | grep "Fetch URL:" | sed -e 's,.*:\(.*\),\1,' -e 's/\.git$//')}

SECRETS_FILE="$HOME/.drone/secrets/$REPO/secrets.yml"

echo "Generating secret for repository: $REPO"
echo "Using secrets from: $SECRETS_FILE"

if [ ! -f "$SECRETS_FILE" ]; then
    echo "Secrets file $SECRETS_FILE does not exist. Aborting.">&2
    exit 1
fi

drone \
    --server https://drone.jodersky.ch \
    --token $(pass infra/drone-token) \
    secure \
    --repo "$REPO" \
    -in "$SECRETS_FILE" \
    -out .drone.sec \
    --yaml .drone.yml \
    --checksum