matacoder

Untitled

May 29th, 2021 (edited)
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.70 KB | None | 0 0
  1. name: Wildberris workflow
  2.  
  3. on:
  4.   push:
  5.     branches:
  6.      - master
  7.  
  8. jobs:
  9.   magic_deploy:
  10.     name: Deploy to server with remote docker-compose
  11.     runs-on: ubuntu-latest
  12.     steps:
  13.       - uses: actions/checkout@v2
  14.       - name: Set up Python
  15.         uses: actions/setup-python@v2
  16.         with:
  17.           python-version: 3.9
  18.  
  19.       - name: Install SSH key to github server
  20.         uses: kielabokkie/ssh-key-and-known-hosts-action@v1.1.0
  21.         with:
  22.           ssh-private-key: ${{ secrets.SSH_KEY }}
  23.           ssh-host: ${{ secrets.IP_HOST }}
  24.  
  25.       - name: Install latest version of docker with experimental compose support
  26.         run: |
  27.          pip install docker-compose
  28.  
  29.       - name: Generate env file from Base64 encoded string (base64 -i .env)
  30.         uses: RollyPeres/base64-to-path@v1
  31.         with:
  32.           filePath: ${{ github.workspace }}/.env
  33.           encodedString: ${{ secrets.ENV }}
  34.  
  35.       - name: Remote docker compose down/up using context (zero files)
  36.         run: |
  37.          docker context create remote --docker "host=ssh://${{ secrets.SSH_USER }}@${{ secrets.IP_HOST }}"
  38.           docker context use remote
  39.           docker image prune -f
  40.           docker-compose --context remote -f docker-compose-prod.yaml down
  41.           docker-compose --context remote -f docker-compose-prod.yaml up -d --build --force-recreate
  42.  
  43.   send_message:
  44.     name: Send telegram notification
  45.     runs-on: ubuntu-latest
  46.     needs: magic_deploy
  47.     steps:
  48.       - name: Send message
  49.         uses: appleboy/telegram-action@master
  50.         with:
  51.           to: ${{ secrets.TELEGRAM_TO }}
  52.           token: ${{ secrets.TELEGRAM_TOKEN }}
  53.           message: ${{ github.workflow }} done!
Add Comment
Please, Sign In to add comment