mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-27 16:10:30 +08:00
added deploy workflow
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
name: Deploy to dev machine
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
stack-name:
|
||||
required: false
|
||||
type: string
|
||||
default: dev
|
||||
image-tag:
|
||||
required: false
|
||||
type: string
|
||||
default: latest
|
||||
backend-port:
|
||||
required: false
|
||||
type: string
|
||||
default: 8080
|
||||
website-port:
|
||||
required: false
|
||||
type: string
|
||||
default: 3000
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
WEB_ADMIN_USERS: ${{ secrets.DEV_WEB_ADMIN_USERS }}
|
||||
WEB_DISCORD_CLIENT_ID: ${{ secrets.DEV_WEB_DISCORD_CLIENT_ID }}
|
||||
WEB_DISCORD_CLIENT_SECRET: ${{ secrets.DEV_WEB_DISCORD_CLIENT_SECRET }}
|
||||
WEB_EMAIL_SERVER_HOST: ${{ secrets.DEV_WEB_EMAIL_SERVER_HOST }}
|
||||
WEB_EMAIL_SERVER_PASSWORD: ${{ secrets.DEV_WEB_EMAIL_SERVER_PASSWORD }}
|
||||
WEB_EMAIL_SERVER_PORT: ${{ secrets.DEV_WEB_EMAIL_SERVER_PORT }}
|
||||
WEB_EMAIL_SERVER_USER: ${{ secrets.DEV_WEB_EMAIL_SERVER_USER }}
|
||||
WEB_NEXTAUTH_SECRET: ${{ secrets.DEV_WEB_NEXTAUTH_SECRET }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Run playbook
|
||||
uses: dawidd6/action-ansible-playbook@v2
|
||||
with:
|
||||
# Required, playbook filepath
|
||||
playbook: deploy-dev.yaml
|
||||
# Optional, directory where playbooks live
|
||||
directory: ansible
|
||||
# Optional, SSH private key
|
||||
key: ${{secrets.DEV_NODE_PRIVATE_KEY}}
|
||||
# Optional, literal inventory file contents
|
||||
inventory: |
|
||||
[dev]
|
||||
dev01 ansible_host=${{secrets.DEV_NODE_IP}} ansible_connection=ssh ansible_user=web-team stack_name=${{inputs.stack-name}} image_tag=${{inputs.image-tag}} backend_port=${{inputs.backend-port}} website_port=${{inputs.website-port}}
|
||||
@@ -46,8 +46,9 @@ jobs:
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ inputs.image-name }}
|
||||
tags: |
|
||||
type=sha,prefix=${{ env.TAG_PREFIX }},format=short
|
||||
type=ref,event=tag
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=sha,prefix=${{ env.TAG_PREFIX }},format=short,enable={{!is_default_branch}}
|
||||
type=ref,event=tag,enable={{!is_default_branch}}
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v3.2.0
|
||||
with:
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
name: pre-commit
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_call:
|
||||
pull_request_target:
|
||||
|
||||
jobs:
|
||||
@@ -18,7 +16,7 @@ jobs:
|
||||
|
||||
# in case of push, check out the main branch
|
||||
- uses: actions/checkout@v3
|
||||
if: github.event_name == 'push'
|
||||
if: github.event_name != 'pull_request_target'
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
release:
|
||||
types: [released]
|
||||
types:
|
||||
- released
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
uses: ./.github/workflows/pre-commit.yaml
|
||||
build-backend:
|
||||
uses: ./.github/workflows/docker-build.yaml
|
||||
with:
|
||||
@@ -28,29 +34,11 @@ jobs:
|
||||
build-args: ""
|
||||
deploy-dev:
|
||||
needs: [build-backend, build-web, build-bot]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
WEB_ADMIN_USERS: ${{ secrets.DEV_WEB_ADMIN_USERS }}
|
||||
WEB_DISCORD_CLIENT_ID: ${{ secrets.DEV_WEB_DISCORD_CLIENT_ID }}
|
||||
WEB_DISCORD_CLIENT_SECRET: ${{ secrets.DEV_WEB_DISCORD_CLIENT_SECRET }}
|
||||
WEB_EMAIL_SERVER_HOST: ${{ secrets.DEV_WEB_EMAIL_SERVER_HOST }}
|
||||
WEB_EMAIL_SERVER_PASSWORD: ${{ secrets.DEV_WEB_EMAIL_SERVER_PASSWORD }}
|
||||
WEB_EMAIL_SERVER_PORT: ${{ secrets.DEV_WEB_EMAIL_SERVER_PORT }}
|
||||
WEB_EMAIL_SERVER_USER: ${{ secrets.DEV_WEB_EMAIL_SERVER_USER }}
|
||||
WEB_NEXTAUTH_SECRET: ${{ secrets.DEV_WEB_NEXTAUTH_SECRET }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Run playbook
|
||||
uses: dawidd6/action-ansible-playbook@v2
|
||||
with:
|
||||
# Required, playbook filepath
|
||||
playbook: dev.yaml
|
||||
# Optional, directory where playbooks live
|
||||
directory: ansible
|
||||
# Optional, SSH private key
|
||||
key: ${{secrets.DEV_NODE_PRIVATE_KEY}}
|
||||
# Optional, literal inventory file contents
|
||||
inventory: |
|
||||
[dev]
|
||||
dev01 ansible_host=${{secrets.DEV_NODE_IP}} ansible_connection=ssh ansible_user=web-team
|
||||
uses: ./.github/workflows/deploy-dev.yaml
|
||||
with:
|
||||
stack-name: ${{ github.event_name == 'release' && 'staging' || 'dev' }}
|
||||
image-tag:
|
||||
${{ github.event_name == 'release' && github.event.release.tag_name ||
|
||||
'latest' }}
|
||||
backend-port: ${{ github.event_name == 'release' && '8080' || '8180' }}
|
||||
website-port: ${{ github.event_name == 'release' && '3000' || '3100' }}
|
||||
|
||||
Reference in New Issue
Block a user