1
mirror of https://github.com/jakejarvis/npqueue.git synced 2025-04-26 06:55:21 -04:00

deploy to heroku with docker and github action

This commit is contained in:
Jake Jarvis 2019-09-11 11:54:11 -04:00
parent 4fbcdbe2a6
commit 016242bcf3
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
5 changed files with 232 additions and 212 deletions

44
.github/workflows/deploy.yml vendored Normal file
View File

@ -0,0 +1,44 @@
name: Deploy
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Lint
uses: actions-contrib/golangci-lint@master
with:
args: run
- name: Setup Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Get dependencies
run: go mod download
- name: Build
run: go build -v .
- name: Heroku Login
uses: actions/heroku@master
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
with:
args: container:login
- name: Heroku Push
uses: actions/heroku@master
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
with:
args: container:push -a npqueue web
- name: Heroku Release
uses: actions/heroku@master
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
with:
args: container:release -a npqueue web

View File

@ -1,40 +0,0 @@
name: Go
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.12
uses: actions/setup-go@v1
with:
go-version: 1.12
id: go
- name: Check out code
uses: actions/checkout@v1
- name: Download and install golangci-lint
run: |
curl -L https://github.com/golangci/golangci-lint/releases/download/v1.17.1/golangci-lint-1.17.1-linux-amd64.tar.gz | tar xzf - -C /tmp
sudo mv /tmp/golangci-lint-1.17.1-linux-amd64/golangci-lint /usr/local/bin/golangci-lint
- name: Run the linter
run: golangci-lint run
- name: Install deps
run: go mod download
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v .

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM golang:1.13 AS builder
WORKDIR /src
COPY . /src
RUN CGO_ENABLED=0 GOOS=linux go build -o npqueue .
# ---
FROM heroku/heroku:18
WORKDIR /app
COPY --from=builder /src /app
ENV GIN_MODE=release
CMD ["./npqueue"]

View File

@ -1,6 +1,6 @@
# [NoPixel Queue List](https://np.pogge.rs/) 👾 # [NoPixel Queue List](https://np.pogge.rs/) 👾
[![Build Status](https://travis-ci.org/jakejarvis/npqueue.svg?branch=master)](https://travis-ci.org/jakejarvis/npqueue) ![](https://github.com/jakejarvis/npqueue/workflows/Deploy/badge.svg)
Active and queued player list for [NoPixel GTA5 RP](https://www.nopixel.net/) server. Based on [@shivammeh/nplists3](https://github.com/shivammeh/nplists3). Active and queued player list for [NoPixel GTA5 RP](https://www.nopixel.net/) server. Based on [@shivammeh/nplists3](https://github.com/shivammeh/nplists3).

View File

@ -14,7 +14,6 @@ import (
"time" "time"
"github.com/gin-gonic/contrib/static" "github.com/gin-gonic/contrib/static"
"github.com/gin-contrib/secure"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
_ "github.com/heroku/x/hmetrics/onload" _ "github.com/heroku/x/hmetrics/onload"
) )
@ -206,7 +205,7 @@ func ListHandler(c *gin.Context) {
func main() { func main() {
port := ":" + os.Getenv("PORT") port := ":" + os.Getenv("PORT")
router := gin.Default() router := gin.Default()
/*
router.Use(secure.New(secure.Config{ router.Use(secure.New(secure.Config{
SSLRedirect: true, SSLRedirect: true,
SSLHost: "np.pogge.rs", SSLHost: "np.pogge.rs",
@ -217,7 +216,7 @@ func main() {
BrowserXssFilter: true, BrowserXssFilter: true,
SSLProxyHeaders: map[string]string{"X-Forwarded-Proto": "https"}, SSLProxyHeaders: map[string]string{"X-Forwarded-Proto": "https"},
})) }))
*/
// Serve frontend static files // Serve frontend static files
router.Use(static.Serve("/", static.LocalFile("./public", true))) router.Use(static.Serve("/", static.LocalFile("./public", true)))
@ -225,7 +224,7 @@ func main() {
api := router.Group("/api") api := router.Group("/api")
{ {
api.GET("/", func(c *gin.Context) { api.GET("/", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H { c.JSON(http.StatusOK, gin.H{
"message": "Nothing to see here.", "message": "Nothing to see here.",
}) })
}) })