This commit is contained in:
50
.gitea/workflows/build-docker.yaml
Normal file
50
.gitea/workflows/build-docker.yaml
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user