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:
|
steps:
|
||||||
- name: Build
|
- name: Build
|
||||||
image: golang
|
image: golang
|
||||||
|
environment:
|
||||||
|
NASA_TOKEN:
|
||||||
|
from_secret: nasa_api
|
||||||
commands:
|
commands:
|
||||||
- go get github.com/reujab/wallpaper
|
- go get github.com/reujab/wallpaper
|
||||||
- go vet -v
|
- go vet -v
|
||||||
- GOOS="linux" go build -o SpaceFace-Linux
|
- GOOS="linux" go build -ldflags="-w -s -x main.api_key=${NASA_TOKEN}" -o SpaceFace-Linux
|
||||||
- GOOS="windows" go build -o SpaceFace-Win.exe
|
- GOOS="windows" go build -ldflags="-w -s -x main.api_key=${NASA_TOKEN}" -o SpaceFace-Win.exe
|
||||||
- GOOS="darwin" go build -o SpaceFace-macOS
|
- GOOS="darwin" go build -ldflags="-w -s -x main.api_key=${NASA_TOKEN}" -o SpaceFace-macOS
|
||||||
- name: gitea_release
|
- name: gitea_release
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
settings:
|
settings:
|
||||||
|
|||||||
7
main.go
7
main.go
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -12,10 +13,14 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
apod APODResponse
|
apod APODResponse
|
||||||
|
api_key string
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
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 {
|
if err != nil {
|
||||||
log.Fatalf("\nUnable to get NASA API Response\n")
|
log.Fatalf("\nUnable to get NASA API Response\n")
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user