add deploy
This commit is contained in:
@@ -45,9 +45,39 @@ jobs:
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/spacesh-landing:${{ steps.version.outputs.VERSION }}
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/spacesh-landing:latest
|
||||
|
||||
# Push the compose stack to the prod host and roll the landing container.
|
||||
# (DMG is uploaded separately from macOS via `make deploy-dmg`.)
|
||||
deploy:
|
||||
name: Deploy to prod
|
||||
needs: landing
|
||||
runs-on: ubuntu-22.04
|
||||
container: catthehacker/ubuntu:act-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
which ssh || (apt-get update && apt-get install -y openssh-client)
|
||||
mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||
printf '%s\n' "${{ secrets.SSH_KEY }}" > ~/.ssh/id_deploy
|
||||
chmod 600 ~/.ssh/id_deploy
|
||||
ssh-keyscan "${{ secrets.SSH_HOST }}" >> ~/.ssh/known_hosts 2>/dev/null || true
|
||||
- name: Sync compose stack
|
||||
run: |
|
||||
ssh -i ~/.ssh/id_deploy "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}" \
|
||||
"mkdir -p '${{ secrets.SSH_REMOTE_DIR }}/download'"
|
||||
# Pin the exact image CI just pushed so the server pulls the right path/tag.
|
||||
printf 'LANDING_IMAGE=%s/%s/spacesh-landing:%s\n' \
|
||||
"${{ env.REGISTRY }}" "${{ env.IMAGE_PREFIX }}" "${{ needs.landing.outputs.version }}" > .env
|
||||
scp -i ~/.ssh/id_deploy deploy/docker-compose.yaml deploy/proxy.conf .env \
|
||||
"${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_REMOTE_DIR }}/"
|
||||
- name: Pull & up
|
||||
run: |
|
||||
ssh -i ~/.ssh/id_deploy "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}" \
|
||||
"cd '${{ secrets.SSH_REMOTE_DIR }}' && docker compose pull && docker compose up -d"
|
||||
|
||||
notify:
|
||||
name: Notify Max
|
||||
needs: landing
|
||||
needs: [landing, deploy]
|
||||
if: always()
|
||||
runs-on: ubuntu-22.04
|
||||
container: catthehacker/ubuntu:act-latest
|
||||
@@ -59,6 +89,12 @@ jobs:
|
||||
failure) line="❌ spacesh-landing — ошибка сборки";;
|
||||
*) line="❔ spacesh-landing — ${{ needs.landing.result }}";;
|
||||
esac
|
||||
case "${{ needs.deploy.result }}" in
|
||||
success) dline="🚀 задеплоен на прод";;
|
||||
failure) dline="❌ деплой упал";;
|
||||
*) dline="❔ деплой — ${{ needs.deploy.result }}";;
|
||||
esac
|
||||
line="$line"$'\n'"$dline"
|
||||
url="${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_number }}"
|
||||
text=$(printf '**Build landing**\n\n%s\n\n[лог](%s)' "$line" "$url")
|
||||
curl -s -X POST "https://platform-api.max.ru/messages?chat_id=${{ secrets.MAX_CHAT_ID }}" \
|
||||
|
||||
Reference in New Issue
Block a user