Create SSL Certificate #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create SSL Certificate | |
on: | |
schedule: | |
- cron: '0 0 15 1,3,5,7,9,11 *' | |
workflow_dispatch: | |
inputs: | |
caname: | |
description: '证书类别' | |
default: all | |
type: choice | |
required: false | |
options: | |
- all | |
- xuexb (ali) | |
- jiandansousuo (ali) | |
- xiaowu (name) | |
env: | |
CA_NAME: ${{ inputs.caname || github.event.inputs.caname || 'all' }} | |
ACME: /home/runner/.acme.sh/acme.sh | |
Ali_Key: ${{ secrets.ALI_KEY }} | |
Ali_Secret: ${{ secrets.ALI_SECRET }} | |
Namecom_Username: ${{ secrets.NAMECOM_USERNAME }} | |
Namecom_Token: ${{ secrets.NAMECOM_TOKEN }} | |
jobs: | |
acme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install ACME.SH | |
run: | | |
curl https://get.acme.sh | sh | |
- uses: actions/checkout@v3 | |
- name: Create xuexb SSL | |
if: ${{ env.CA_NAME == 'all' || startsWith(env.CA_NAME, 'xuexb') }} | |
run: | | |
mkdir -p ./ca/xuexb | |
$ACME --issue \ | |
--server letsencrypt \ | |
--dns dns_ali \ | |
--log \ | |
-d "xuexb.com" \ | |
-d "xuexb.cn" \ | |
-d "*.xuexb.cn" \ | |
-d "*.xuexb.com" \ | |
-d "*.static.xuexb.com" \ | |
-d "*.dev.xuexb.com" \ | |
-d "*.proxy.xuexb.com" \ | |
-d "*.api.xuexb.com" | |
$ACME --installcert \ | |
-d "xuexb.com" \ | |
--key-file ./ca/xuexb/xuexb.key \ | |
--fullchain-file ./ca/xuexb/xuexb.cer | |
- name: Create jiandansousuo SSL | |
if: ${{ env.CA_NAME == 'all' || startsWith(env.CA_NAME, 'jiandansousuo') }} | |
run: | | |
mkdir -p ./ca/jiandansousuo | |
$ACME --issue \ | |
--server letsencrypt \ | |
--dns dns_ali \ | |
--log \ | |
-d "jiandansousuo.com" \ | |
-d "jiandansousuo.cn" \ | |
-d "*.jiandansousuo.cn" \ | |
-d "*.jiandansousuo.com" | |
$ACME --installcert \ | |
-d "jiandansousuo.com" \ | |
--key-file ./ca/jiandansousuo/jiandansousuo.key \ | |
--fullchain-file ./ca/jiandansousuo/jiandansousuo.cer | |
- name: Create xiaowu SSL | |
if: ${{ env.CA_NAME == 'all' || startsWith(env.CA_NAME, 'xiaowu') }} | |
run: | | |
mkdir -p ./ca/xiaowu | |
$ACME --issue \ | |
--server letsencrypt \ | |
--dns dns_namecom \ | |
--log \ | |
-d "xiaowu.dev" \ | |
-d "*.xiaowu.dev" \ | |
-d "jiandansousuo.org" \ | |
-d "*.jiandansousuo.org" \ | |
-d "apijs.org" \ | |
-d "*.apijs.org" \ | |
-d "kakawoniu.com" \ | |
-d "*.kakawoniu.com" \ | |
-d "shangxian.app" \ | |
-d "*.shangxian.app" \ | |
-d "xiaoshuo.io" \ | |
-d "*.xiaoshuo.io" | |
$ACME --installcert \ | |
-d "xiaowu.dev" \ | |
--key-file ./ca/xiaowu/xiaowu.key \ | |
--fullchain-file ./ca/xiaowu/xiaowu.cer | |
- name: Git push | |
if: ${{ success() }} | |
run: | | |
git config user.name xuexb | |
git config user.email [email protected] | |
git add . | |
git commit -m "feat: Add SSL - ${{ env.CA_NAME }}" | |
git push | |
git tag "ssl-$(date "+%Y%m%d")" | |
git push --tags | |
call-publish: | |
runs-on: ubuntu-latest | |
needs: acme | |
if: ${{ needs.acme.result == 'success' }} | |
steps: | |
- uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.WORKFLOW_TOKEN }} | |
script: | | |
try { | |
const result = github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: "publish.yml", | |
ref: "master", | |
}); | |
console.log(result); | |
} catch(error) { | |
console.error(error); | |
core.setFailed(error); | |
} |