From cc9ccc4e9b44a6e703a8df3c13398a208090b818 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Fri, 26 Aug 2022 19:06:32 +0800 Subject: [PATCH] ci: auto generate drivers lang file --- .github/workflows/auto_lang.yml | 59 +++++++++++++++++++++++++++++++++ drivers/virtual/meta.go | 9 +++-- pkg/utils/json.go | 2 +- 3 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/auto_lang.yml diff --git a/.github/workflows/auto_lang.yml b/.github/workflows/auto_lang.yml new file mode 100644 index 00000000..10685f9a --- /dev/null +++ b/.github/workflows/auto_lang.yml @@ -0,0 +1,59 @@ +name: auto_lang + +on: + push: + branches: [ '**' ] + +jobs: + auto_lang: + strategy: + matrix: + platform: [ ubuntu-latest ] + go-version: [ 1.19 ] + name: auto generate lang.json + runs-on: ${{ matrix.platform }} + steps: + - name: Setup go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout alist + uses: actions/checkout@v2 + with: + path: alist + + - name: Checkout alist-web + uses: actions/checkout@v3 + with: + repository: 'alist-org/alist-web' + ref: 'auto_lang' + persist-credentials: false + fetch-depth: 0 + path: alist-web + + - name: Generate lang + run: | + cd alist + go run ./main.go lang + cd .. + - name: Copy lang file + run: | + cp -f ./alist/drivers.json ./alist-web/src/lang/en/ + + - name: Commit git + run: | + cd alist-web + git add . + git config --local user.email "i@nn.ci" + git config --local user.name "Noah Hsu" + git commit --allow-empty -m "chore: update drivers translate file" -a + cd .. + + - name: Upload lang files + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.MY_TOKEN }} + branch: auto_lang + directory: alist-web + repository: alist-org/alist-web \ No newline at end of file diff --git a/drivers/virtual/meta.go b/drivers/virtual/meta.go index 5b621766..13575f93 100644 --- a/drivers/virtual/meta.go +++ b/drivers/virtual/meta.go @@ -7,11 +7,10 @@ import ( type Addition struct { driver.RootFolderPath - NumFile int `json:"num_file" type:"number" default:"30" required:"true"` - NumFolder int `json:"num_folder" type:"number" default:"30" required:"true"` - MaxFileSize int64 `json:"max_file_size" type:"number" default:"1073741824" required:"true"` - MinFileSize int64 `json:"min_file_size" type:"number" default:"1048576" required:"true"` - TestSelect string `json:"test_select" type:"select" options:"a,b,c"` + NumFile int `json:"num_file" type:"number" default:"30" required:"true"` + NumFolder int `json:"num_folder" type:"number" default:"30" required:"true"` + MaxFileSize int64 `json:"max_file_size" type:"number" default:"1073741824" required:"true"` + MinFileSize int64 `json:"min_file_size" type:"number" default:"1048576" required:"true"` } var config = driver.Config{ diff --git a/pkg/utils/json.go b/pkg/utils/json.go index cfb1b779..5dea3650 100644 --- a/pkg/utils/json.go +++ b/pkg/utils/json.go @@ -11,7 +11,7 @@ var Json = json.ConfigCompatibleWithStandardLibrary // WriteJsonToFile write struct to json file func WriteJsonToFile(dst string, data interface{}) bool { - str, err := Json.MarshalIndent(data, "", " ") + str, err := json.MarshalIndent(data, "", " ") if err != nil { log.Errorf("failed convert Conf to []byte:%s", err.Error()) return false