Add API key for drone automated builds
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@ -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
7
main.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user