-
Notifications
You must be signed in to change notification settings - Fork 4
94 lines (80 loc) · 2.62 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: CI/CD Hamster workflow
on: push
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
python-version: 3.12.2
- name: Install requirements
run: pip install -r requirements-dev.txt
- name: Lint Ruff
run: ruff check .
- name: Lint Flake8
run: flake8 .
build_and_push_to_dockerhub:
runs-on: ubuntu-latest
needs: lint
if: github.ref == 'refs/heads/main'
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/hamster_bot:${{ github.sha }}
deploy:
runs-on: ubuntu-latest
needs: build_and_push_to_dockerhub
if: github.ref == 'refs/heads/main'
steps:
- name: executing remote ssh commands to deploy
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.SSHKEY }}
script: |
scp docker-compose.prod.yml redis.conf ${{ secrets.USERNAME }}@${{ secrets.HOST }}:/home/ubuntu/Hamster-generator/
cd /home/ubuntu/Hamster-generator
sudo docker-compose down
export IMAGE_TAG=${{ github.sha }}
docker-compose -f docker-compose.prod.yml --env-file .env.prod up -d
create-release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: build_and_push_to_dockerhub
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: v1.8.0
name: "Release v1.8.0"
body: |
Dockerhub deploy. New workflow. Message to telegram | 🏖️
token: ${{ secrets.GITHUB_TOKEN }}
send_message:
runs-on: ubuntu-latest
needs: deploy
steps:
- name: send message to Telegram
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
${{ github.workflow }} successfully completed!
Version: ${{ github.ref_name }}