CD #223
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: CD | |
on: | |
workflow_run: | |
workflows: | |
- CI | |
types: | |
- completed | |
jobs: | |
cd: | |
runs-on: sg | |
if: github.event.workflow_run.conclusion == 'success' | |
steps: | |
- name: Download Artifct | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: CI | |
workflow_conclusion: success | |
run_id: ${{ github.event.workflow_run.id }} | |
run_number: ${{ github.event.workflow_run.run_number }} | |
name: sub_account_${{ github.event.workflow_run.head_commit.id }} | |
- name: Deploy | |
run: | | |
host_name="" | |
branch="${{ github.event.workflow_run.head_branch }}" | |
if [[ "$branch" == "dev" ]]; then | |
host_name="backendtest" | |
elif [[ "$branch" == "test3" ]]; then | |
host_name="backendtest3" | |
else | |
echo "Skipping build and deploy for branch ${branch}" | |
exit 1 | |
fi | |
rsync -a sub_account root@"$host_name":/mnt/das/server/sub-account-svr/sub_account | |
ssh root@"$host_name" 'chmod +x /mnt/das/server/sub-account-svr/sub_account' | |
ssh root@"$host_name" 'supervisorctl restart sub_svr' |