Skip to content
This repository was archived by the owner on Jul 22, 2022. It is now read-only.

Commit ea2ea80

Browse files
author
Your Name
committed
Getting github data in action
1 parent cbb47d9 commit ea2ea80

File tree

7 files changed

+84
-26
lines changed

7 files changed

+84
-26
lines changed

Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
# Container image that runs your code
2-
FROM alpine:3.10
1+
FROM golang:alpine AS build-env
32

4-
# Copies your code file from your action repository to the filesystem path `/` of the container
5-
COPY entrypoint.sh /entrypoint.sh
3+
WORKDIR /go/src/app
64

7-
# Code file to execute when the docker container starts up (`entrypoint.sh`)
8-
ENTRYPOINT ["/entrypoint.sh"]
5+
COPY go.mod .
6+
COPY go.sum .
7+
RUN go mod download
8+
9+
COPY . .
10+
11+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o /go/bin/main
12+
13+
FROM alpine
14+
COPY --from=build-env /go/bin/main /go/bin/main
15+
ENTRYPOINT ["/go/bin/main"]
916

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22

33
This Github action finds changes to your dependencies in pull requests, and helps you track review of those changes.
44

5-
## Example
5+
## Running inside Github Actions
6+
7+
xxx
8+
9+
## Running inside Docker locally
10+
11+
Build image:
12+
docker build -t go-review-action .
13+
14+
Run the image:
15+
docker run -it -e GITHUB_TOKEN --rm --name go-review-action go-review-action
16+
17+
## Running locally with go
18+
19+
Run with:
20+
go run app.go
21+
22+
623

7-
See xxx
824

action.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
# action.yml
2-
name: 'Hello World'
3-
description: 'Greet someone and record the time'
4-
inputs:
5-
who-to-greet: # id of input
6-
description: 'Who to greet'
7-
required: true
8-
default: 'World'
9-
outputs:
10-
time: # id of output
11-
description: 'The time we greeted you'
2+
name: 'Go dependency review helper'
3+
description: 'Help under changes to dependencies through review'
124
runs:
135
using: 'docker'
146
image: 'Dockerfile'
15-
args:
16-
- ${{ inputs.who-to-greet }}

entrypoint.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module main
2+
3+
require (
4+
github.com/google/go-github v17.0.0+incompatible
5+
github.com/google/go-github/v28 v28.1.1
6+
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
7+
)

go.sum

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2+
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
3+
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
4+
github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM=
5+
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
6+
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
7+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
8+
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
9+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
10+
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
11+
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
12+
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
13+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
14+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
15+
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=

main.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/google/go-github/github"
7+
"golang.org/x/oauth2"
8+
"os"
9+
)
10+
11+
func main() {
12+
fmt.Println("Started!")
13+
14+
ctx := context.Background()
15+
ts := oauth2.StaticTokenSource(
16+
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
17+
)
18+
tc := oauth2.NewClient(ctx, ts)
19+
fmt.Println("Client created!")
20+
21+
client := github.NewClient(tc)
22+
fmt.Println("Github client created!")
23+
24+
// list all repositories for the authenticated user
25+
repos, _, err := client.Repositories.List(ctx, "", nil)
26+
27+
fmt.Println(repos)
28+
fmt.Println(err)
29+
}

0 commit comments

Comments
 (0)