diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d877232 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,44 @@ +name: CI + +# Controls when the action will run. Triggers the workflow on push to master or development +# with a tag like v1.0.0 or v1.0.0-dev +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+ + - v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]+ + +jobs: + build: + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Get Version + id: get_version + uses: battila7/get-version-action@v2.0.0 + + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: goff + IMAGE_TAG: ${{ steps.get_version.outputs.version-without-v }} + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest + docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest diff --git a/Dockerfile b/Dockerfile index ac585ff..e5c5618 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,20 @@ -FROM golang:1.14-alpine +FROM golang:1.14-alpine as dev WORKDIR /go/src/Goff COPY ./go.mod . +COPY ./go.sum . -RUN apk add --no-cache git - -RUN go get -d -v ./... +RUN go mod download COPY . . -RUN go install -v ./... +RUN go install github.com/dustinpianalto/goff -ENTRYPOINT /go/bin/goff +CMD [ "go", "run", "goff.go"] + +from alpine + +WORKDIR /bin + +COPY --from=dev /go/bin/goff ./goff + +CMD [ "goff" ] diff --git a/djpianalto.com/goff/events/member_events.go b/events/member_events.go similarity index 98% rename from djpianalto.com/goff/events/member_events.go rename to events/member_events.go index c3fc370..ebc0755 100644 --- a/djpianalto.com/goff/events/member_events.go +++ b/events/member_events.go @@ -1,12 +1,13 @@ package events import ( - "djpianalto.com/goff/djpianalto.com/goff/utils" "fmt" - "github.com/bwmarrin/discordgo" "log" "strconv" "time" + + "github.com/bwmarrin/discordgo" + "github.com/dustinpianalto/goff/utils" ) func OnGuildMemberAddLogging(s *discordgo.Session, member *discordgo.GuildMemberAdd) { diff --git a/djpianalto.com/goff/events/message_events.go b/events/message_events.go similarity index 98% rename from djpianalto.com/goff/events/message_events.go rename to events/message_events.go index 96d3abb..5167a82 100644 --- a/djpianalto.com/goff/events/message_events.go +++ b/events/message_events.go @@ -4,8 +4,8 @@ import ( "fmt" "log" - "djpianalto.com/goff/djpianalto.com/goff/utils" "github.com/bwmarrin/discordgo" + "github.com/dustinpianalto/goff/utils" ) func OnMessageUpdate(session *discordgo.Session, m *discordgo.MessageUpdate) { diff --git a/djpianalto.com/goff/exts/P_interpreter.go b/exts/P_interpreter.go similarity index 100% rename from djpianalto.com/goff/exts/P_interpreter.go rename to exts/P_interpreter.go diff --git a/djpianalto.com/goff/exts/fun.go b/exts/fun.go similarity index 100% rename from djpianalto.com/goff/exts/fun.go rename to exts/fun.go diff --git a/djpianalto.com/goff/exts/guild.go b/exts/guild.go similarity index 99% rename from djpianalto.com/goff/exts/guild.go rename to exts/guild.go index 960934b..b5da4bc 100644 --- a/djpianalto.com/goff/exts/guild.go +++ b/exts/guild.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "djpianalto.com/goff/djpianalto.com/goff/utils" "github.com/dustinpianalto/disgoman" + "github.com/dustinpianalto/goff/utils" ) // Guild management commands diff --git a/djpianalto.com/goff/exts/init.go b/exts/init.go similarity index 100% rename from djpianalto.com/goff/exts/init.go rename to exts/init.go diff --git a/djpianalto.com/goff/exts/tags.go b/exts/tags.go similarity index 98% rename from djpianalto.com/goff/exts/tags.go rename to exts/tags.go index 4a55771..6839a7e 100644 --- a/djpianalto.com/goff/exts/tags.go +++ b/exts/tags.go @@ -6,8 +6,8 @@ import ( "log" "strings" - "djpianalto.com/goff/djpianalto.com/goff/utils" "github.com/dustinpianalto/disgoman" + "github.com/dustinpianalto/goff/utils" "github.com/kballard/go-shellquote" ) diff --git a/djpianalto.com/goff/exts/tasks.go b/exts/tasks.go similarity index 96% rename from djpianalto.com/goff/exts/tasks.go rename to exts/tasks.go index 6239f1d..fa54327 100644 --- a/djpianalto.com/goff/exts/tasks.go +++ b/exts/tasks.go @@ -1,15 +1,16 @@ package exts import ( - "djpianalto.com/goff/djpianalto.com/goff/utils" "errors" "fmt" + "strings" + "time" + "github.com/dustinpianalto/disgoman" + "github.com/dustinpianalto/goff/utils" "github.com/olebedev/when" "github.com/olebedev/when/rules/common" "github.com/olebedev/when/rules/en" - "strings" - "time" ) func addReminderCommand(ctx disgoman.Context, args []string) { diff --git a/djpianalto.com/goff/exts/user_management.go b/exts/user_management.go similarity index 99% rename from djpianalto.com/goff/exts/user_management.go rename to exts/user_management.go index f5a5594..08c5bc3 100644 --- a/djpianalto.com/goff/exts/user_management.go +++ b/exts/user_management.go @@ -1,13 +1,14 @@ package exts import ( - "djpianalto.com/goff/djpianalto.com/goff/utils" "errors" "fmt" - "github.com/bwmarrin/discordgo" - "github.com/dustinpianalto/disgoman" "strings" "time" + + "github.com/bwmarrin/discordgo" + "github.com/dustinpianalto/disgoman" + "github.com/dustinpianalto/goff/utils" ) func kickUserCommand(ctx disgoman.Context, args []string) { diff --git a/djpianalto.com/goff/exts/utils.go b/exts/utils.go similarity index 98% rename from djpianalto.com/goff/exts/utils.go rename to exts/utils.go index b8a2056..4a0e3f6 100644 --- a/djpianalto.com/goff/exts/utils.go +++ b/exts/utils.go @@ -1,14 +1,15 @@ package exts import ( - "djpianalto.com/goff/djpianalto.com/goff/utils" "fmt" - "github.com/bwmarrin/discordgo" - "github.com/dustinpianalto/disgoman" "sort" "strconv" "strings" "time" + + "github.com/bwmarrin/discordgo" + "github.com/dustinpianalto/disgoman" + "github.com/dustinpianalto/goff/utils" ) func pingCommand(ctx disgoman.Context, _ []string) { diff --git a/go.mod b/go.mod index 29d07d6..92010e8 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,13 @@ -module djpianalto.com/goff +module github.com/dustinpianalto/goff go 1.14 require ( github.com/bwmarrin/discordgo v0.20.3-0.20200525154655-ca64123b05de github.com/dustinpianalto/disgoman v0.0.10 + github.com/dustinpianalto/rpnparse v1.0.1 github.com/emersion/go-imap v1.0.5 github.com/emersion/go-message v0.12.0 - github.com/dustinpianalto/rpnparse v1.0.1 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/lib/pq v1.3.0 github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254 diff --git a/djpianalto.com/goff/goff.go b/goff.go similarity index 95% rename from djpianalto.com/goff/goff.go rename to goff.go index 4bf65cc..08a4124 100644 --- a/djpianalto.com/goff/goff.go +++ b/goff.go @@ -4,10 +4,10 @@ import ( "fmt" "log" - "djpianalto.com/goff/djpianalto.com/goff/events" - "djpianalto.com/goff/djpianalto.com/goff/exts" - "djpianalto.com/goff/djpianalto.com/goff/utils" "github.com/dustinpianalto/disgoman" + "github.com/dustinpianalto/goff/events" + "github.com/dustinpianalto/goff/exts" + "github.com/dustinpianalto/goff/utils" //"github.com/MikeModder/anpan" "os" diff --git a/djpianalto.com/goff/utils/database.go b/utils/database.go similarity index 100% rename from djpianalto.com/goff/utils/database.go rename to utils/database.go diff --git a/djpianalto.com/goff/utils/date_strings.go b/utils/date_strings.go similarity index 100% rename from djpianalto.com/goff/utils/date_strings.go rename to utils/date_strings.go diff --git a/djpianalto.com/goff/utils/email.go b/utils/email.go similarity index 100% rename from djpianalto.com/goff/utils/email.go rename to utils/email.go diff --git a/djpianalto.com/goff/utils/logging.go b/utils/logging.go similarity index 100% rename from djpianalto.com/goff/utils/logging.go rename to utils/logging.go diff --git a/djpianalto.com/goff/utils/postfixes.go b/utils/postfixes.go similarity index 100% rename from djpianalto.com/goff/utils/postfixes.go rename to utils/postfixes.go diff --git a/djpianalto.com/goff/utils/puzzles.go b/utils/puzzles.go similarity index 100% rename from djpianalto.com/goff/utils/puzzles.go rename to utils/puzzles.go diff --git a/djpianalto.com/goff/utils/rpn.go b/utils/rpn.go similarity index 100% rename from djpianalto.com/goff/utils/rpn.go rename to utils/rpn.go diff --git a/djpianalto.com/goff/utils/rpnParser.go b/utils/rpnParser.go similarity index 100% rename from djpianalto.com/goff/utils/rpnParser.go rename to utils/rpnParser.go diff --git a/djpianalto.com/goff/utils/snowflake.go b/utils/snowflake.go similarity index 100% rename from djpianalto.com/goff/utils/snowflake.go rename to utils/snowflake.go diff --git a/djpianalto.com/goff/utils/tasks.go b/utils/tasks.go similarity index 100% rename from djpianalto.com/goff/utils/tasks.go rename to utils/tasks.go diff --git a/djpianalto.com/goff/utils/types.go b/utils/types.go similarity index 100% rename from djpianalto.com/goff/utils/types.go rename to utils/types.go