Skip to content

Commit

Permalink
ci(deploy,.github): update
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyungent committed Apr 13, 2022
1 parent d071f9d commit ab37ab6
Show file tree
Hide file tree
Showing 18 changed files with 398 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/QQBotHub-docker-push-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Docker Image CI/CD - Beta - Dragonfly

on:
push:
branches: [ main ]

jobs:
# build and push
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Get latest release
id: last_release
uses: InsonusK/[email protected]
with:
myToken: ${{ github.token }}
exclude_types: "release, prerelease"
view_top: 1

- name: Set outputs
id: vars
run: |
echo ::set-output name=IMAGE_NAME::qqbothub
- name: Build Image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ steps.vars.outputs.IMAGE_NAME }}:${{ steps.last_release.outputs.tag_name }}-beta -f src/WebApi/Dockerfile .
- name: Login to Registry - Docker Hub
run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}

- name: Push Image - Docker
# push: last_release-beta
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/${{ steps.vars.outputs.IMAGE_NAME }}:${{ steps.last_release.outputs.tag_name }}-beta
- name: Login to Registry - ghcr.io
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push Image - ghcr.io
# push: last_release-beta
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${{ steps.vars.outputs.IMAGE_NAME }}
VERSION=${{ steps.last_release.outputs.tag_name }}-beta
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag ${{ secrets.DOCKER_USERNAME }}/${{ steps.vars.outputs.IMAGE_NAME }}:${{ steps.last_release.outputs.tag_name }}-beta $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
52 changes: 52 additions & 0 deletions .github/workflows/QQBotHub-docker-push-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Docker Image CI/CD - Release - Dragonfly

on:
# release:
# types: [published]
push:
tags:
- 'QQBotHub-v*'

jobs:
# build and push
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set outputs
id: vars
run: |
#echo ::set-output name=RELEASE_VERSION::$(echo ${GITHUB_REF:10})
# 去掉前面的 refs/tags/QQBotHub-
echo ::set-output name=RELEASE_VERSION::$(echo ${GITHUB_REF:19})
echo ::set-output name=IMAGE_NAME::qqbothub
- name: Build Image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ steps.vars.outputs.IMAGE_NAME }}:${{ steps.vars.outputs.RELEASE_VERSION }} -f src/WebApi/Dockerfile .
- name: Login to Registry - Docker Hub
run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}

- name: Push Image - Docker Hub
# push: RELEASE_VERSION, latest
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/${{ steps.vars.outputs.IMAGE_NAME }}:${{ steps.vars.outputs.RELEASE_VERSION }}
docker tag ${{ secrets.DOCKER_USERNAME }}/${{ steps.vars.outputs.IMAGE_NAME }}:${{ steps.vars.outputs.RELEASE_VERSION }} ${{ secrets.DOCKER_USERNAME }}/${{ steps.vars.outputs.IMAGE_NAME }}:latest
docker push ${{ secrets.DOCKER_USERNAME }}/${{ steps.vars.outputs.IMAGE_NAME }}:latest
- name: Login to Registry - ghcr.io
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push Image - ghcr.io
# push: RELEASE_VERSION, latest
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${{ steps.vars.outputs.IMAGE_NAME }}
VERSION=${{ steps.vars.outputs.RELEASE_VERSION }}
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag ${{ secrets.DOCKER_USERNAME }}/${{ steps.vars.outputs.IMAGE_NAME }}:latest $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
docker tag $IMAGE_ID:$VERSION $IMAGE_ID:latest
docker push $IMAGE_ID:latest
67 changes: 67 additions & 0 deletions .github/workflows/QQBotHub-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: QQBotHub Release

on:
push:
tags:
- 'QQBotHub-v*'

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100

- name: Build
run: |
cd ./src/QQBotHub.Web
# win-x64
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true --output ../../win-x64 --self-contained true
# win-x86
dotnet publish -c Release -r win-x86 -p:PublishSingleFile=true --output ../../win-x86 --self-contained true
# linux-x64
dotnet publish -c Release -r linux-x64 -p:PublishSingleFile=true --output ../../linux-x64 --self-contained true
# linux-arm
dotnet publish -c Release -r linux-arm -p:PublishSingleFile=true --output ../../linux-arm --self-contained true
# linux-arm64
dotnet publish -c Release -r linux-arm64 -p:PublishSingleFile=true --output ../../linux-arm64 --self-contained true
# osx-x64
dotnet publish -c Release -r osx-x64 -p:PublishSingleFile=true --output ../../osx-x64 --self-contained true
# osx.10.10-x64
dotnet publish -c Release -r osx.10.10-x64 -p:PublishSingleFile=true --output ../../osx.10.10-x64 --self-contained true
- name: Zip the Build
run: |
zip -r QQBotHub-win-x64.zip ./win-x64/
zip -r QQBotHub-win-x86.zip ./win-x86/
zip -r QQBotHub-linux-x64.zip ./linux-x64/
zip -r QQBotHub-linux-arm.zip ./linux-arm/
zip -r QQBotHub-linux-arm64.zip ./linux-arm64/
zip -r QQBotHub-osx-x64.zip ./osx-x64/
zip -r QQBotHub-osx.10.10-x64.zip ./osx.10.10-x64/
- name: Create Release and Upload Release Asset
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
#tag_name: ${{ github.ref }}
#name: ${{ github.ref }}
body: TODO New Release.
#body_path: CHANGELOG.txt
draft: false
prerelease: false
files: |
QQBotHub-win-x64.zip
QQBotHub-win-x86.zip
QQBotHub-linux-x64.zip
QQBotHub-linux-arm.zip
QQBotHub-linux-arm64.zip
QQBotHub-osx-x64.zip
QQBotHub-osx.10.10-x64.zip
49 changes: 49 additions & 0 deletions .github/workflows/QQHelloWorldPlugin-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: QQHelloWorldPlugin Release

on:
push:
tags:
- 'QQHelloWorldPlugin-v*'

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100

- name: Build
run: |
cd ./plugins/QQHelloWorldPlugin
dotnet build --configuration Release
ls
ls ./bin/Release/
- name: Zip the Build
run: |
cd ./plugins/QQHelloWorldPlugin/bin/Release
zip -r QQHelloWorldPlugin-net6.0.zip ./net6.0/
cd ../../../../
mv ./src/QQHelloWorldPlugin/bin/Release/*.zip ./
- name: Create Release and Upload Release Asset
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
#tag_name: ${{ github.ref }}
#name: ${{ github.ref }}
body: TODO New Release.
#body_path: CHANGELOG.txt
draft: false
prerelease: false
files: |
QQHelloWorldPlugin-net6.0.zip
LICENSE
README.md
20 changes: 20 additions & 0 deletions .github/workflows/sync-gitee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Sync to Gitee

on:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Sync to Gitee
uses: wearerequired/git-mirror-action@master
env:
# 在 Settings->Secrets 配置 GITEE_SSH_PRIVATE_KEY
SSH_PRIVATE_KEY: ${{ secrets.GITEE_SSH_PRIVATE_KEY }}
with:
# GitHub 源仓库地址
source-repo: [email protected]:yiyungent/QQBotHub.git
# Gitee 目标仓库地址
destination-repo: [email protected]:yiyungent/QQBotHub.git
32 changes: 32 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "QQBotHub",
"description": "QQ 机器人 | 基于 Konata.Core - Heroku Deploy",
"keywords": ["yiyungent", "QQBotHub"],
"website": "https://github.com/yiyungent/QQBotHub",
"repository": "https://github.com/yiyungent/QQBotHub",
"success_url": "/",
"env": {
"PLUGINCORE_ADMIN_USERNAME": {
"description": "PluginCore Admin 用户名",
"value": "admin",
"required": true
},
"PLUGINCORE_ADMIN_PASSWORD": {
"description": "PluginCore Admin 密码",
"value": "ABC12345",
"required": true
},
"BOT_QQ": {
"description": "机器人 QQ",
"value": "",
"required": true
},
"BOT_PASSWORD": {
"description": "机器人 QQ 密码",
"value": "",
"required": true
}
},

"stack": "container"
}
9 changes: 9 additions & 0 deletions deploy/flyio/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# fly.io Dockerfile

FROM yiyungent/dragonfly:v0.1.3

ADD flyio-entrypoint.sh ./flyio-entrypoint.sh
RUN chmod +x ./flyio-entrypoint.sh
ADD flyio-PluginCore.Config.json ./flyio-PluginCore.Config.json

ENTRYPOINT ["/bin/sh", "./flyio-entrypoint.sh"]
1 change: 1 addition & 0 deletions deploy/flyio/flyio-PluginCore.Config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Admin":{"UserName":"PLUGINCORE_ADMIN_USERNAME","Password":"PLUGINCORE_ADMIN_PASSWORD"},"FrontendMode":"LocalEmbedded","RemoteFrontend":"https://cdn.jsdelivr.net/gh/yiyungent/[email protected]/dist-cdn","PluginWidgetDebug":false}
21 changes: 21 additions & 0 deletions deploy/flyio/flyio-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

# region env
export ASPNETCORE_URLS="http://+:$PORT"
export ASPNETCORE_ENVIRONMENT="Production"
export TZ="Asia/Shanghai"
# endregion env

# region PluginCore
echo ${PLUGINCORE_ADMIN_USERNAME}
echo ${PLUGINCORE_ADMIN_PASSWORD}

mkdir App_Data

touch /app/App_Data/PluginCore.Config.json

cat '/app/heroku-PluginCore.Config.json' | sed "s/PLUGINCORE_ADMIN_USERNAME/${PLUGINCORE_ADMIN_USERNAME}/g" | tee '/app/App_Data/PluginCore.Config.json'
cat '/app/App_Data/PluginCore.Config.json' | sed "s/PLUGINCORE_ADMIN_PASSWORD/${PLUGINCORE_ADMIN_PASSWORD}/g" | tee '/app/App_Data/PluginCore.Config.json'
# endregion PluginCore

dotnet WebApi.dll
13 changes: 13 additions & 0 deletions deploy/heroku/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Heroku Dockerfile

FROM yiyungent/qqbothub:v0.0.1

# 处于 /app 目录下
ADD heroku-entrypoint.sh ./heroku-entrypoint.sh
RUN chmod +x ./heroku-entrypoint.sh
ADD heroku-PluginCore.Config.json ./heroku-PluginCore.Config.json

RUN rm /app/settings.json
ADD settings.json ./settings.json

ENTRYPOINT ["/bin/sh", "./heroku-entrypoint.sh"]
1 change: 1 addition & 0 deletions deploy/heroku/heroku-PluginCore.Config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Admin":{"UserName":"PLUGINCORE_ADMIN_USERNAME","Password":"PLUGINCORE_ADMIN_PASSWORD"},"FrontendMode":"LocalEmbedded","RemoteFrontend":"https://cdn.jsdelivr.net/gh/yiyungent/[email protected]/dist-cdn","PluginWidgetDebug":false}
29 changes: 29 additions & 0 deletions deploy/heroku/heroku-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# region env
export ASPNETCORE_URLS="http://+:$PORT"
export ASPNETCORE_ENVIRONMENT="Production"
export TZ="Asia/Shanghai"
# endregion env

# region PluginCore
echo ${PLUGINCORE_ADMIN_USERNAME}
echo ${PLUGINCORE_ADMIN_PASSWORD}

mkdir App_Data

touch /app/App_Data/PluginCore.Config.json

cat '/app/heroku-PluginCore.Config.json' | sed "s/PLUGINCORE_ADMIN_USERNAME/${PLUGINCORE_ADMIN_USERNAME}/g" | tee '/app/App_Data/PluginCore.Config.json'
cat '/app/App_Data/PluginCore.Config.json' | sed "s/PLUGINCORE_ADMIN_PASSWORD/${PLUGINCORE_ADMIN_PASSWORD}/g" | tee '/app/App_Data/PluginCore.Config.json'
# endregion PluginCore

# region QQ Bot
echo ${BOT_QQ}
echo ${BOT_PASSWORD}

cat '/app/settings.json' | sed "s/BOT_QQ/${BOT_QQ}/g" | tee '/app/settings.json'
cat '/app/settings.json' | sed "s/BOT_PASSWORD/${BOT_PASSWORD}/g" | tee '/app/settings.json'
# endregion QQ Bot

dotnet WebApi.dll
4 changes: 4 additions & 0 deletions deploy/heroku/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"QQ": "BOT_QQ",
"Password": "BOT_PASSWORD"
}
13 changes: 13 additions & 0 deletions deploy/railway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Railway Dockerfile

FROM yiyungent/qqbothub:v0.0.1

# 处于 /app 目录下
ADD railway-entrypoint.sh ./railway-entrypoint.sh
RUN chmod +x ./railway-entrypoint.sh
ADD railway-PluginCore.Config.json ./railway-PluginCore.Config.json

RUN rm /app/settings.json
ADD settings.json ./settings.json

ENTRYPOINT ["/bin/sh", "./railway-entrypoint.sh"]
1 change: 1 addition & 0 deletions deploy/railway/railway-PluginCore.Config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Admin":{"UserName":"PLUGINCORE_ADMIN_USERNAME","Password":"PLUGINCORE_ADMIN_PASSWORD"},"FrontendMode":"LocalEmbedded","RemoteFrontend":"https://cdn.jsdelivr.net/gh/yiyungent/[email protected]/dist-cdn","PluginWidgetDebug":false}
Loading

0 comments on commit ab37ab6

Please sign in to comment.