name: Build and Push Dogecoin Node on: push: branches: [main] schedule: - cron: '0 0 * * *' # Run daily at midnight UTC jobs: build-and-push: runs-on: docker://ubuntu:latest steps: # Checkout the repository - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 # Fetch full history for commit # Set up workspace - name: Set up workspace run: | mkdir -p $HOME/bin echo "$HOME/bin" >> $GITHUB_PATH # Install jq for JSON parsing - name: Install jq run: | curl -L -o $HOME/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 chmod +x $HOME/bin/jq jq --version # Get latest Dogecoin version - name: Get latest Dogecoin version id: get-version run: | LATEST_VERSION=$(curl -s https://api.github.com/repos/dogecoin/dogecoin/releases/latest | jq -r '.tag_name' | sed 's/^v//') echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV # Check last built version - name: Check last built version id: check-version run: | if [ -f last_version.txt ]; then LAST_VERSION=$(cat last_version.txt) else LAST_VERSION="0.0.0" fi echo "LAST_VERSION=$LAST_VERSION" >> $GITHUB_ENV # Compare versions (e.g., 1.14.9 vs 1.14.8) if [ "$(printf '%s\n' "$LATEST_VERSION" "$LAST_VERSION" | sort -V | tail -n1)" = "$LATEST_VERSION" ] && [ "$LATEST_VERSION" != "$LAST_VERSION" ]; then echo "New version detected: $LATEST_VERSION > $LAST_VERSION" echo "BUILD_REQUIRED=true" >> $GITHUB_ENV else echo "No new version: $LATEST_VERSION <= $LAST_VERSION" echo "BUILD_REQUIRED=false" >> $GITHUB_ENV fi # Set up QEMU for multiarch builds (only if build is required) - name: Set up QEMU if: env.BUILD_REQUIRED == 'true' uses: docker/setup-qemu-action@v2 # Set up Docker Buildx (only if build is required) - name: Set up Docker Buildx if: env.BUILD_REQUIRED == 'true' uses: docker/setup-buildx-action@v2 # Log in to Gitea Registry (only if build is required) - name: Login to Gitea Registry if: env.BUILD_REQUIRED == 'true' uses: docker/login-action@v2 with: registry: gitea.ivangodwin.com username: ${{ secrets.GITEA_USERNAME }} password: ${{ secrets.GITEA_TOKEN }} # Build and push multiarch image (only if build is required) - name: Build and push if: env.BUILD_REQUIRED == 'true' uses: docker/build-push-action@v4 with: context: . file: docker/Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: gitea.ivangodwin.com/ivangodwin/dogecoin-node:latest,gitea.ivangodwin.com/ivangodwin/dogecoin-node:${{ env.LATEST_VERSION }} build-args: | DOGECOIN_VERSION=${{ env.LATEST_VERSION }} # Update last_version.txt and commit (only if build is required) - name: Update last built version if: env.BUILD_REQUIRED == 'true' run: | echo "${{ env.LATEST_VERSION }}" > last_version.txt git config user.name "Gitea Actions" git config user.email "actions@gitea.ivangodwin.com" git add last_version.txt git commit -m "Update last built Dogecoin version to ${{ env.LATEST_VERSION }}" git push