diff --git a/README.md b/README.md index e2cc334..f188a43 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,12 @@ jobs: ## Options 🔧 | Name | Description | Default | Required | |:--------:|:--------------------------------:|:--------------:|:--------:| -| username | Your username | - | ✅ | -| reponame | Your repository name | - | ✅ | -| token | Please leave this line unchanged | - | ✅ | -| gitemail | Git commit email | CI@example.com | ❌ | -| gitname | Git commit name | CI | ❌ | -| gitmsg | Git commit message | deploy | ❌ | -| cname | Custom domain | - | ❌ | -| useyarn | Use yarn to build | false | ❌ | +| username | Your username | - | ✅ | +| reponame | Your repository name | - | ✅ | +| token | Please leave this line unchanged | - | ✅ | +| branch | Default branch name | main | ❌ | +| cname | Custom domain | - | ❌ | +| gitemail | Git commit email | CI@example.com | ❌ | +| gitmsg | Git commit message | deploy | ❌ | +| gitname | Git commit name | CI | ❌ | +| useyarn | Use yarn to build | false | ❌ | diff --git a/action.yml b/action.yml index b07c2ad..7f4f5bb 100644 --- a/action.yml +++ b/action.yml @@ -13,22 +13,26 @@ inputs: token: description: 'Your Github token' required: true + branch: + description: 'Default branch name' + required: false + default: 'main' + cname: + description: 'Your custom domain' + required: false + default: 'none' gitemail: description: 'Your git commit email' required: false default: 'CI@example.com' - gitname: - description: 'Your git commit name' - required: false - default: 'CI' gitmsg: description: 'Your git commit message' required: false default: 'deploy' - cname: - description: 'Your custom domain' + gitname: + description: 'Your git commit name' required: false - default: 'none' + default: 'CI' useyarn: description: 'Use yarn to build' required: false @@ -41,12 +45,13 @@ runs: if [ true == ${{ inputs.useyarn }} ]; then yarn install --frozen-lockfile; else npm ci; fi if [ true == ${{ inputs.useyarn }} ]; then yarn build; else npm run build; fi cd dist - ln -s index.html 404.html + [ -f 404.html ] || ln -s index.html 404.html if [ "none" != ${{ inputs.cname }} ]; then echo '${{ inputs.cname }}' > CNAME; fi + git config --global init.defaultBranch "${{ inputs.branch }}" git config --global user.email "${{ inputs.gitemail }}" git config --global user.name "${{ inputs.gitname }}" git init git add -A git commit -m '${{ inputs.gitmsg }}' - git push -f https://${{ inputs.username }}:${{ inputs.token }}@github.com/${{ inputs.username }}/${{ inputs.reponame }}.git master:gh-pages + git push -f https://${{ inputs.username }}:${{ inputs.token }}@github.com/${{ inputs.username }}/${{ inputs.reponame }}.git ${{ inputs.branch }}:gh-pages shell: bash