Skip to content

Commit

Permalink
Merge pull request #2 from codescalers/create-dockerfile-and-makefile
Browse files Browse the repository at this point in the history
Create dockerfile and makefile
  • Loading branch information
AbdelrahmanElawady authored Nov 7, 2023
2 parents 7eed9ee + 8cc1556 commit bbda35e
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 6 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lint

on:
push:
workflow_dispatch:

jobs:
Lint:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Install GO
uses: actions/setup-go@v3
with:
go-version: 1.21

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout 3m --verbose

- name: staticcheck
uses: dominikh/[email protected]
with:
version: "2022.1.3"

- name: gofmt
uses: Jerome1337/[email protected]
with:
gofmt-flags: "-l -d"

19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:1.21-alpine as builder

WORKDIR /src

COPY . .

RUN go mod tidy

RUN go build -o statusbot main.go


FROM alpine

WORKDIR /app

COPY --from=builder /src/statusbot .

CMD ./statusbot -t ${STATUSBOT_TOKEN}

39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
GOPATH := $(shell go env GOPATH)

getverifiers:
@echo "Installing staticcheck" && go get -u honnef.co/go/tools/cmd/staticcheck && go install honnef.co/go/tools/cmd/staticcheck
@echo "Installing gocyclo" && go get -u github.com/fzipp/gocyclo/cmd/gocyclo && go install github.com/fzipp/gocyclo/cmd/gocyclo
@echo "Installing deadcode" && go get -u github.com/remyoudompheng/go-misc/deadcode && go install github.com/remyoudompheng/go-misc/deadcode
@echo "Installing misspell" && go get -u github.com/client9/misspell/cmd/misspell && go install github.com/client9/misspell/cmd/misspell
@echo "Installing golangci-lint" && go install github.com/golangci/golangci-lint/cmd/[email protected]
go mod tidy

verifiers: fmt lint cyclo deadcode spelling staticcheck

fmt:
@echo "Running $@"
@gofmt -d .

lint:
@echo "Running $@"
@${GOPATH}/bin/golangci-lint run

cyclo:
@echo "Running $@"
@${GOPATH}/bin/gocyclo -over 100 .

deadcode:
@echo "Running $@"
@${GOPATH}/bin/deadcode -test $(shell go list ./...) || true

spelling:
@echo "Running $@"
@${GOPATH}/bin/misspell -i monitord -error `find .`

staticcheck:
@echo "Running $@"
@${GOPATH}/bin/staticcheck -- ./...

build:
@echo "Running $@"
@go build -o statusbot main.go
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
# statusbot
# Statusbot

## Overview

The Status Bot is a tool designed to send a reminder at 5 O'clock

## Getting Started

### Prerequisites

Ensure that you have installed:

- Go programming language (version 1.21 or higher if not using docker)
- Git

### How to start

1. Clone this repository to your local machine:

```bash
git clone https://github.com/codescalers/statusbot
cd statusbot
```

2. Setup your telegram bot and your env

- Create a new [telegram bot](README.md#create-a-bot) if you don't have.

3. Run the bot:

- Using go

```bash
go run main.go -t <your bot token>
```

- Using Docker

```bash
docker build -t statusbot .
docker run -e <your bot token> -it statusbot
```

## Create a bot

- Open telegram app
- Create a new bot

```ordered
1. Find telegram bot named "@botfarther"
2. Type /newbot
```

- Get the bot token

```ordered
1. In the same bot named "@botfarther"
2. Type /token
3. Choose your bot
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/codescalers/statusbot

go 1.21.3
go 1.21

require (
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
Expand Down
4 changes: 0 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package main

import "github.com/codescalers/statusbot/cmd"
Expand Down

0 comments on commit bbda35e

Please sign in to comment.