Adds deploy
This commit is contained in:
parent
b778d91196
commit
117fe1e5c3
1 changed files with 77 additions and 0 deletions
77
.forgejo/workflows/cicd.yml
Normal file
77
.forgejo/workflows/cicd.yml
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
name: AppAIBuildTest-cicd
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_test_deploy_test:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: "9.0.x"
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: dotnet test -c Release
|
||||||
|
|
||||||
|
- name: Publish (self-contained linux-x64)
|
||||||
|
run: dotnet publish -c Release -r linux-x64 --self-contained true -o out
|
||||||
|
|
||||||
|
- name: Install deploy tools
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y rsync openssh-client
|
||||||
|
|
||||||
|
- name: Deploy TEST
|
||||||
|
env:
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
chmod 700 ~/.ssh
|
||||||
|
echo "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
rsync -az --delete out/ "$DEPLOY_USER@$DEPLOY_HOST:/opt/appaibuiltest-test/app/"
|
||||||
|
ssh "$DEPLOY_USER@$DEPLOY_HOST" "chmod +x /opt/appaibuiltest-test/app/AppAIBuildTest && sudo systemctl restart appaibuiltest-test"
|
||||||
|
|
||||||
|
deploy_prod_manual:
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: "9.0.x"
|
||||||
|
|
||||||
|
- name: Publish (self-contained linux-x64)
|
||||||
|
run: dotnet publish -c Release -r linux-x64 --self-contained true -o out
|
||||||
|
|
||||||
|
- name: Install deploy tools
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y rsync openssh-client
|
||||||
|
|
||||||
|
- name: Deploy PROD
|
||||||
|
env:
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
chmod 700 ~/.ssh
|
||||||
|
echo "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
rsync -az --delete out/ "$DEPLOY_USER@$DEPLOY_HOST:/opt/appaibuiltest/app/"
|
||||||
|
ssh "$DEPLOY_USER@$DEPLOY_HOST" "chmod +x /opt/appaibuiltest/app/AppAIBuildTest && sudo systemctl restart appaibuiltest"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue