CI
All checks were successful
Build Docker Image / build (amd64) (push) Successful in 1m40s

This commit is contained in:
thuanle
2024-10-24 10:05:04 +07:00
parent 92a63c7885
commit b60fcb842d
7 changed files with 81 additions and 3 deletions

View File

@@ -0,0 +1,50 @@
name: Build Docker Image
on:
push:
branches:
- main
jobs:
build:
strategy:
matrix:
arch:
- amd64
runs-on: ${{ matrix.arch }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history, keeping all commits
- name: Get commit count
id: get_commit_count
run: |
COMMIT_COUNT=$(git rev-list --count HEAD)
echo "COMMIT_COUNT=${COMMIT_COUNT}" >> $GITHUB_ENV
- name: Prepare code
run: |
echo "Preparing versioning"
echo "package configs" > internal/configs/version.go
echo "var Version = \"${{ env.COMMIT_COUNT }}\"" >> internal/configs/version.go
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: git.thuanle.me
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker images
run: |
echo "Building image for architecture: ${{ matrix.arch }} with commit count: ${{ env.COMMIT_COUNT }}"
docker build -f Dockerfile \
-t git.thuanle.me/public/crypto-price-bot:${{ matrix.arch }}-${{ env.COMMIT_COUNT }} \
-t git.thuanle.me/public/crypto-price-bot:latest \
.
docker push git.thuanle.me/public/crypto-price-bot:${{ matrix.arch }}-${{ env.COMMIT_COUNT }}
docker push git.thuanle.me/public/crypto-price-bot:latest

9
.idea/crypto-price-bot.iml generated Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/crypto-price-bot.iml" filepath="$PROJECT_DIR$/.idea/crypto-price-bot.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -0,0 +1,3 @@
package configs
var Version = "2"

View File

@@ -31,7 +31,7 @@ func setupCommands(b *telebot.Bot) error {
b.Handle("/start", commands.OnStart)
//general
b.Handle("/ip", commands.OnGetIp)
b.Handle("/v", commands.OnGetVersion)
//info
b.Handle("/p", commands.OnGetTopPrices)

View File

@@ -2,11 +2,13 @@ package commands
import (
"gopkg.in/telebot.v3"
"me.thuanle/bbot/internal/configs"
"me.thuanle/bbot/internal/services/tele/chat"
"me.thuanle/bbot/internal/utils/netx"
)
func OnGetIp(context telebot.Context) error {
func OnGetVersion(context telebot.Context) error {
ip := netx.GetPublicIp()
return chat.ReplyMessageCode(context, ip)
msg := "v" + configs.Version + " - " + ip
return chat.ReplyMessageCode(context, msg)
}