From 5bfedf1ee8ebf10aa62069515210d0aef82a2b88 Mon Sep 17 00:00:00 2001 From: Ivan Godwin Date: Sat, 3 May 2025 02:59:12 -0700 Subject: [PATCH] initial add of build action --- .gitea/build-dogecoing.yml | 90 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .gitea/build-dogecoing.yml diff --git a/.gitea/build-dogecoing.yml b/.gitea/build-dogecoing.yml new file mode 100644 index 0000000..f0da157 --- /dev/null +++ b/.gitea/build-dogecoing.yml @@ -0,0 +1,90 @@ +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: ubuntu-latest + steps: + # Checkout the repository + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch full history for commit + + # Install jq for JSON parsing + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + + # 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 \ No newline at end of file