Skip to content

Commit

Permalink
use the github token of the action itself
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Apr 18, 2023
1 parent 42c6c4d commit 108edef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/check-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
issues:
types: [opened, edited]

permissions:
issues: write

jobs:
run:
runs-on: ubuntu-latest
Expand All @@ -21,5 +24,5 @@ jobs:

- name: check
env:
ROD_GITHUB_ROBOT: ${{secrets.ROD_GITHUB_ROBOT}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd lib/utils/check-issue && go run .
6 changes: 4 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ name: Release docker image

on: [push, pull_request]

permissions: write-all

jobs:
# TODO: we should merge job docker-amd and job docker-arm once the github actions fix their issue with cross-platform building.
docker-amd:
Expand All @@ -23,7 +25,7 @@ jobs:

- run: go run ./lib/docker $GITHUB_REF
env:
DOCKER_TOKEN: ${{secrets.ROD_GITHUB_ROBOT}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- uses: actions/upload-artifact@v2
with:
Expand All @@ -50,5 +52,5 @@ jobs:

- run: go run ./lib/docker $GITHUB_REF
env:
DOCKER_TOKEN: ${{secrets.ROD_GITHUB_ROBOT}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ARCH: arm
4 changes: 2 additions & 2 deletions lib/docker/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The .github/workflows/docker.yml uses it as an github action
// and run it like this:
//
// DOCKER_TOKEN=$TOKEN go run ./lib/utils/docker $GITHUB_REF
// GITHUB_TOKEN=$TOKEN go run ./lib/utils/docker $GITHUB_REF
package main

import (
Expand Down Expand Up @@ -85,7 +85,7 @@ func test(at archType) {
}

func login() {
cmd := exec.Command("docker", "login", "-u=rod-robot", "-p", os.Getenv("DOCKER_TOKEN"), registry)
cmd := exec.Command("docker", "login", "-u=rod-robot", "-p", os.Getenv("GITHUB_TOKEN"), registry)
out, err := cmd.CombinedOutput()
utils.E(err)
utils.E(os.Stdout.Write(out))
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/check-issue/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The .github/workflows/check-issues.yml will use it as an github action
// To test it locally, you can generate a personal github token: https://github.com/settings/tokens
// Then run this:
// ROD_GITHUB_ROBOT=your_token go run ./lib/utils/check-issue
// GITHUB_TOKEN=your_token go run ./lib/utils/check-issue

package main

Expand Down Expand Up @@ -98,7 +98,7 @@ func deleteComments(id int) {
}

func req(u string) *http.Request {
token := os.Getenv("ROD_GITHUB_ROBOT")
token := os.Getenv("GITHUB_TOKEN")
if token == "" {
panic("missing github token")
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/check-issue/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func TestBasic(t *testing.T) {
g := got.T(t)

_ = os.Setenv("ROD_GITHUB_ROBOT", "1234")
_ = os.Setenv("GITHUB_TOKEN", "1234")

body := g.Read(g.Open(false, "body-invalid.txt")).String()

Expand Down

0 comments on commit 108edef

Please sign in to comment.