Browse Source

Add API key for drone automated builds

master
Gregory Rudolph 3 years ago
parent
commit
14d163c058
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 9
      .drone.yml
  2. 7
      main.go

9
.drone.yml

@ -5,12 +5,15 @@ name: default @@ -5,12 +5,15 @@ name: default
steps:
- name: Build
image: golang
environment:
NASA_TOKEN:
from_secret: nasa_api
commands:
- go get github.com/reujab/wallpaper
- go vet -v
- GOOS="linux" go build -o SpaceFace-Linux
- GOOS="windows" go build -o SpaceFace-Win.exe
- GOOS="darwin" go build -o SpaceFace-macOS
- GOOS="linux" go build -ldflags="-w -s -x main.api_key=${NASA_TOKEN}" -o SpaceFace-Linux
- GOOS="windows" go build -ldflags="-w -s -x main.api_key=${NASA_TOKEN}" -o SpaceFace-Win.exe
- GOOS="darwin" go build -ldflags="-w -s -x main.api_key=${NASA_TOKEN}" -o SpaceFace-macOS
- name: gitea_release
image: plugins/gitea-release
settings:

7
main.go

@ -2,6 +2,7 @@ package main @@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
@ -12,10 +13,14 @@ import ( @@ -12,10 +13,14 @@ import (
var (
apod APODResponse
api_key string
)
func main() {
resp, err := http.Get("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY")
if len(api_key) == 0 {
api_key="DEMO_KEY"
}
resp, err := http.Get(fmt.Sprintf("https://api.nasa.gov/planetary/apod?api_key=%+v", api_key))
if err != nil {
log.Fatalf("\nUnable to get NASA API Response\n")
return

Loading…
Cancel
Save