build: git password for push
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nyyu 2022-06-25 11:23:01 +02:00
parent 2f1878ab42
commit 43a4af1b8f
2 changed files with 6 additions and 3 deletions

View File

@ -19,7 +19,7 @@ steps:
- "echo 'build ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers" - "echo 'build ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
- chown -R build:build . - chown -R build:build .
- sudo -u build --preserve-env=PGP_KEY,PGP_PWD,PGP_ID sh -c 'mkdir ~/.gnupg && echo -e "default-cache-ttl 3600\nallow-preset-passphrase" > ~/.gnupg/gpg-agent.conf && echo "$PGP_KEY" | gpg --import --no-tty --batch --yes && echo "$PGP_PWD" | /usr/lib/gnupg/gpg-preset-passphrase --preset $PGP_ID' - sudo -u build --preserve-env=PGP_KEY,PGP_PWD,PGP_ID sh -c 'mkdir ~/.gnupg && echo -e "default-cache-ttl 3600\nallow-preset-passphrase" > ~/.gnupg/gpg-agent.conf && echo "$PGP_KEY" | gpg --import --no-tty --batch --yes && echo "$PGP_PWD" | /usr/lib/gnupg/gpg-preset-passphrase --preset $PGP_ID'
- sudo -u build --preserve-env=DRONE_GIT_HTTP_URL,DRONE_SOURCE_BRANCH sh -c './build.sh' - sudo -u build --preserve-env=DRONE_GIT_HTTP_URL,DRONE_SOURCE_BRANCH,GIT_PASSWORD sh -c './build.sh'
environment: environment:
PGP_KEY: PGP_KEY:
from_secret: PGP_KEY from_secret: PGP_KEY
@ -27,6 +27,8 @@ steps:
from_secret: PGP_PWD from_secret: PGP_PWD
PGP_ID: PGP_ID:
from_secret: PGP_ID from_secret: PGP_ID
GIT_PASSWORD:
from_secret: git_password
volumes: volumes:
- name: repo - name: repo
host: host:

View File

@ -30,9 +30,10 @@ build() {
} }
env env
git config --global user.email "drone@nyyu.dev" git config user.email "drone@nyyu.dev"
git config --global user.name "drone" git config user.name "drone"
git remote set-url origin $DRONE_GIT_HTTP_URL git remote set-url origin $DRONE_GIT_HTTP_URL
git config credential.helper '!f() { sleep 1; echo "username=drone"; echo "password=${GIT_PASSWORD}"; }; f'
for d in */ ; do for d in */ ; do
cd "$d" || continue cd "$d" || continue