Skip to content

Commit

Permalink
ci: auto generate drivers lang file
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 26, 2022
1 parent 7425e00 commit cc9ccc4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 6 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/auto_lang.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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
9 changes: 4 additions & 5 deletions drivers/virtual/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc9ccc4

Please sign in to comment.