Skip to content

Commit

Permalink
decouple github
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Apr 26, 2021
1 parent d899afc commit f80084d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:

- uses: actions/checkout@v2

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

- uses: actions/upload-artifact@v2
with:
Expand Down
14 changes: 7 additions & 7 deletions lib/utils/docker/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// The .github/workflows/docker.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 GITHUB_REF=refs/heads/master go run ./lib/utils/docker
// DOCKER_TOKEN=your_token go run ./lib/utils/docker refs/heads/master
package main

import (
Expand All @@ -17,14 +16,15 @@ import (
const registry = "ghcr.io"
const image = registry + "/go-rod/rod"

var ref = os.Getenv("GITHUB_REF")
var token = os.Getenv("ROD_GITHUB_ROBOT")
var token = os.Getenv("DOCKER_TOKEN")

func main() {
fmt.Println("GITHUB_REF:", ref)
event := os.Args[1]

master := regexp.MustCompile(`^refs/heads/master$`).MatchString(ref)
m := regexp.MustCompile(`^refs/tags/(v[0-9]+\.[0-9]+\.[0-9]+)$`).FindStringSubmatch(ref)
fmt.Println("Event:", event)

master := regexp.MustCompile(`^refs/heads/master$`).MatchString(event)
m := regexp.MustCompile(`^refs/tags/(v[0-9]+\.[0-9]+\.[0-9]+)$`).FindStringSubmatch(event)
ver := ""
if len(m) > 1 {
ver = m[1]
Expand Down

0 comments on commit f80084d

Please sign in to comment.