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