Skip to content

Commit

Permalink
hack: Add weekly-gen to Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
at15 committed Feb 18, 2020
1 parent abb88a6 commit aa6843c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# Builder
# https://steele.blue/tiny-github-actions/
FROM dyweb/go-dev:1.13.6 as builder

LABEL maintainer="[email protected]"

ARG PROJECT_ROOT=/go/src/github.com/dyweb/weekly

ENV WEEKLY_GEN_VERSION=v0.3.5
WORKDIR $PROJECT_ROOT

RUN curl -sSL https://github.com/dyweb/dy-weekly-generator/releases/download/$WEEKLY_GEN_VERSION/dy-weekly-generator-$WEEKLY_GEN_VERSION-x86_64-unknown-linux-gnu.tar.gz \
| tar -vxz -C /usr/bin
COPY . $PROJECT_ROOT
RUN cd scripts/weekly && go install .

# Runner
FROM ubuntu:18.04
LABEL maintainer="[email protected]"
# NOTE: libssl is required by weekly-gen
RUN apt update && apt install -y libssl1.0.0

WORKDIR /usr/bin

COPY --from=builder /usr/bin/weekly-gen .
COPY --from=builder /go/bin/weekly .

ENTRYPOINT ["weekly"]
CMD ["help"]
5 changes: 4 additions & 1 deletion scripts/weekly/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/dyweb/weekly/scripts/weekly

go 1.13

require github.com/spf13/cobra v0.0.5 // indirect
require (
github.com/dyweb/gommon v0.0.13
github.com/spf13/cobra v0.0.5
)
13 changes: 13 additions & 0 deletions scripts/weekly/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dyweb/gommon v0.0.13 h1:SwEex1UakZJVpO37GqiTc0QQ7iOe5Rz+6hQnGh1UePo=
github.com/dyweb/gommon v0.0.13/go.mod h1:cdTMuWn9B/9F87Jza4nwI6Ka8z+uT5+WcGDWWKFhnqM=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand All @@ -22,11 +29,17 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
27 changes: 25 additions & 2 deletions scripts/weekly/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package main
import (
"fmt"
"os"
"os/exec"
"strconv"

"github.com/dyweb/gommon/errors"
"github.com/dyweb/gommon/util/fsutil"
"github.com/spf13/cobra"
)

Expand All @@ -22,8 +26,8 @@ func main() {
issueCmd := &cobra.Command{
Use: "issue",
Short: "Reconcile issue",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("TODO: fetch issues, close old one and create new one")
RunE: func(cmd *cobra.Command, args []string) error {
return build()
},
}
rootCmd.AddCommand(issueCmd)
Expand All @@ -32,3 +36,22 @@ func main() {
os.Exit(1)
}
}

// Based on https://github.com/dyweb/dy-bot/blob/master/pkg/weekly/weekly.go#L14 buildWeekly
// shell out to weekly-gen binary from https://github.com/dyweb/dy-weekly-generator
// weekly-gen --repo dyweb/weekly --issue 183
func build() error {
// TODO:
issue := 183
cmd := exec.Command("weekly-gen", "--repo", "dyweb/weekly", "--issue", strconv.Itoa(issue))
out, err := cmd.CombinedOutput()
if err != nil {
return errors.Wrapf(err, "error running weekly-gen %s", string(out))
}
// TODO: get weekly number based on issue
dst := "TODO.md"
if err = fsutil.WriteFile(dst, out); err != nil {
return errors.Wrapf(err, "error writing weekly-gen output to %s", dst)
}
return nil
}

0 comments on commit aa6843c

Please sign in to comment.