-
Notifications
You must be signed in to change notification settings - Fork 4
96 lines (84 loc) · 2.63 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
95
96
name: CI/CD Hamster workflow
on: push
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- 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:v1.8.3
deploy:
runs-on: ubuntu-latest
needs: build_and_push_to_dockerhub
steps:
- uses: actions/checkout@v2
- name: Copy repository contents via scp
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.SSHKEY }}
source: "redis.conf,docker-compose.prod.yml"
target: "/home/${{ secrets.USERNAME }}/Hamster-generator"
- name: Execute deployment commands
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.SSHKEY }}
script: |
cd /home/ubuntu/Hamster-generator
ls -la
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.3
name: "Release v1.8.3"
body: |
Dockerhub deploy. New workflow. Message to telegram. Final release | 🏖️
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 }}