Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker release #14

Merged
merged 4 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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