Skip to content

Commit

Permalink
Merge pull request #14 from tobifroe/docker-release
Browse files Browse the repository at this point in the history
Docker release
  • Loading branch information
tobifroe authored Jul 13, 2024
2 parents 214ff2a + 77a4049 commit 524a027
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 10 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,26 @@ jobs:
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: tobiasfrolich/starscraper:${{ github.ref_name }}
5 changes: 4 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
- name: Test
run: make test

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

RUN apk add make

WORKDIR /app

COPY . /app

RUN make build-docker

ENTRYPOINT ["./starscraper"]
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ build:
@echo "GOPATH=${GOPATH}"
go build -ldflags "-X github.com/tobifroe/starscraper/version.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X github.com/tobifroe/starscraper/version.BuildDate=${BUILD_DATE}" -o bin/${BIN_NAME}

build-docker:
@echo "building ${BIN_NAME} ${VERSION}"
@echo "GOPATH=${GOPATH}"
go build -ldflags "-X github.com/tobifroe/starscraper/version.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X github.com/tobifroe/starscraper/version.BuildDate=${BUILD_DATE}" -o ${BIN_NAME}


get-deps:
go mod download

Expand Down
11 changes: 8 additions & 3 deletions cmd/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ func init() {
scrapeCmd.Flags().String("output", "output.csv", "Output file")
scrapeCmd.Flags().BoolP("verbose", "v", false, "Verbose output")

scrapeCmd.MarkFlagRequired("repo")
scrapeCmd.MarkFlagRequired("owner")

err := scrapeCmd.MarkFlagRequired("repo")
if err != nil {
panic(err)
}
err = scrapeCmd.MarkFlagRequired("owner")
if err != nil {
panic(err)
}
}
13 changes: 9 additions & 4 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,23 @@ func WriteToCSV(users []types.User, output string) {
defer writer.Flush()

headers := []string{"email", "name", "login"}
writer.Write(headers)
err = writer.Write(headers)
if err != nil {
panic(err)
}
for _, row := range users {
s := []string{
row.Email,
row.Name,
row.Login,
}
writer.Write(s)
err = writer.Write(s)
if err != nil {
panic(err)
}
}
}

// TODO implement/document client secret parsing, Write to Docs mode
func WriteToGoogleDocs(sheetFlag *string, allUsers []types.User) {
return
// TODO implement/document client secret parsing, Write to Docs mode
}
5 changes: 4 additions & 1 deletion util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ func TestWriteToCSV(t *testing.T) {
}

// Validate CSV format
file.Seek(0, 0)
_, err = file.Seek(0, 0)
if err != nil {
panic(err)
}
var buf bytes.Buffer
_, _ = buf.ReadFrom(file)
csvContent := buf.String()
Expand Down

0 comments on commit 524a027

Please sign in to comment.