포트 수정, 리드미 수정 #2
This file contains hidden or 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: deploy-mori-soc | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| env: | |
| DEPLOY_PATH: /backup/rmstudio/mori | |
| DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} | |
| DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }} | |
| DEPLOY_USER: ${{ secrets.DEPLOY_USER }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Start SSH agent | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }} | |
| - name: Add SSH known hosts | |
| run: | | |
| mkdir -p ~/.ssh | |
| if [ -n "${{ secrets.DEPLOY_KNOWN_HOSTS }}" ]; then | |
| printf '%s\n' "${{ secrets.DEPLOY_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts | |
| else | |
| ssh-keyscan -p "$DEPLOY_PORT" "$DEPLOY_HOST" >> ~/.ssh/known_hosts | |
| fi | |
| - name: Ensure remote path exists | |
| run: ssh -p "$DEPLOY_PORT" "$DEPLOY_USER@$DEPLOY_HOST" "mkdir -p '$DEPLOY_PATH'" | |
| - name: Sync repository | |
| run: | | |
| rsync -az --delete \ | |
| --exclude '.git/' \ | |
| --exclude '.env' \ | |
| --exclude 'certs/' \ | |
| --exclude 'reports/' \ | |
| --exclude 'config/wazuh_indexer_ssl_certs/' \ | |
| ./ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/" | |
| - name: Upload deployment env | |
| env: | |
| DEPLOY_ENV_FILE: ${{ secrets.DEPLOY_ENV_FILE }} | |
| run: | | |
| printf '%s' "$DEPLOY_ENV_FILE" | \ | |
| ssh -p "$DEPLOY_PORT" "$DEPLOY_USER@$DEPLOY_HOST" "cat > '$DEPLOY_PATH/.env'" | |
| - name: Run remote deploy | |
| run: | | |
| ssh -p "$DEPLOY_PORT" "$DEPLOY_USER@$DEPLOY_HOST" <<EOF | |
| set -e | |
| cd "$DEPLOY_PATH" | |
| mkdir -p certs reports config/wazuh_indexer_ssl_certs | |
| if [ ! -f config/wazuh_indexer_ssl_certs/root-ca.pem ]; then | |
| docker compose -f generate-indexer-certs.yml run --rm generator | |
| fi | |
| docker compose pull | |
| docker compose up -d --remove-orphans | |
| docker compose ps | |
| EOF |