led-christmas-tree/.drone.yml

63 lines
2.1 KiB
YAML

---
kind: pipeline
type: docker
name: build-platofrmio
steps:
- name: detectURLs
image: archlinux
commands:
- gitea_domain=$(echo "$DRONE_GIT_HTTP_URL" | awk -F "://" '{print $2}' | awk -F ".git" '{print tolower($1)}' | awk -F "/" '{print $1}')
- gitea_user=$(echo "$DRONE_GIT_HTTP_URL" | awk -F "://" '{print $2}' | awk -F ".git" '{print tolower($1)}' | awk -F "/" '{print $2}')
- gitea_repo=$(echo "$DRONE_GIT_HTTP_URL" | awk -F "://" '{print $2}' | awk -F ".git" '{print tolower($1)}' | awk -F "/" '{print $3}')
- echo "gitea_domain=$gitea_domain" >> .env
- echo "gitea_user=$gitea_user" >> .env
- echo "gitea_repo=$gitea_repo" >> .env
- cat .env
- name: build
image: jonasled.dev/jonasled/platformio-docker:latest
commands:
- pio run
- name: upload-to-gitea
image: alpine
environment:
DOCKER_PASSWORD:
from_secret: DOCKER_PASSWORD
commands:
- source .env
- apk add --no-cache curl
- package_link="https://$gitea_domain/api/packages/$gitea_user/generic/$gitea_repo/$DRONE_BRANCH/firmware.bin"
- |
if ! curl -s --head --user "$gitea_user:$DOCKER_PASSWORD" --request GET "$package_link" | grep "404 Not Found" > /dev/null
then
echo "File already exists, deleting it"
curl --user "$gitea_user:$DOCKER_PASSWORD" -X DELETE "$package_link"
fi
- curl --user "$gitea_user:$DOCKER_PASSWORD" --upload-file ".pio/build/d1_mini_lite/firmware.bin" $package_link
when:
event:
- push
- name: upload-to-transfersh
image: archlinux
commands:
- pacman -Syu --noconfirm curl
- download_url=$(curl --upload-file "f.pio/build/d1_mini_lite/firmware.bin" "https://transfer.jonasled.de")
- echo "download_url=$download_url" >> .env
- 'echo "Download URL: $download_url" > comment.txt'
when:
event:
- pull_request
- name: add comment to gitea pull request
image: tsakidev/giteacomment:latest
settings:
gitea_token:
from_secret: gitea_token
gitea_base_url: https://jonasled.dev
comment_title: 'Build finished'
comment_from_file: comment.txt
when:
event:
- pull_request