name: Build and Push Docker Image on: push: branches: - main tags: - 'v*' jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-tags: true - name: Set version id: vars run: | if [ -n "$GIT_TAG" ]; then VERSION="$GIT_TAG" else VERSION="latest" fi echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Build image run: docker build -t zxc . - name: Login to Gitea registry run: | echo "${{ secrets.CICD_PASSWORD }}" | docker login git.home.db123.ir -u username --password-stdin - name: Tag image run: | docker tag zxc git.home.db123.ir/username/zxc:latest if [ "$VERSION" != "latest" ]; then docker tag zxc git.home.db123.ir/username/zxc:$VERSION fi - name: Push images run: | docker push git.home.db123.ir/username/zxc:latest if [ "$VERSION" != "latest" ]; then docker push git.home.db123.ir/username/zxc:$VERSION fi