BTC Data Updater #5217
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: BTC Data Updater | |
| on: | |
| # Executa automaticamente a cada 30 minutos | |
| schedule: | |
| - cron: "*/30 * * * *" | |
| # Permite execu莽茫o manual via GitHub UI | |
| workflow_dispatch: | |
| jobs: | |
| update-btc-data: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 25 | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run BTC Data Updater | |
| env: | |
| quicknode_endpoint_1: ${{ secrets.QUICKNODE_ENDPOINT_1 }} | |
| quicknode_endpoint_2: ${{ secrets.QUICKNODE_ENDPOINT_2 }} | |
| quicknode_endpoint_3: ${{ secrets.QUICKNODE_ENDPOINT_3 }} | |
| quicknode_endpoint_4: ${{ secrets.QUICKNODE_ENDPOINT_4 }} | |
| quicknode_endpoint_5: ${{ secrets.QUICKNODE_ENDPOINT_5 }} | |
| quicknode_endpoint_6: ${{ secrets.QUICKNODE_ENDPOINT_6 }} | |
| quicknode_endpoint_7: ${{ secrets.QUICKNODE_ENDPOINT_7 }} | |
| quicknode_endpoint_8: ${{ secrets.QUICKNODE_ENDPOINT_8 }} | |
| quicknode_endpoint_9: ${{ secrets.QUICKNODE_ENDPOINT_9 }} | |
| quicknode_endpoint_10: ${{ secrets.QUICKNODE_ENDPOINT_10 }} | |
| run: python ./main.py | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| - name: Check for changes | |
| id: git-check | |
| run: | | |
| git add data/ | |
| if git diff --staged --quiet; then | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and Push changes | |
| if: steps.git-check.outputs.changes == 'true' | |
| run: | | |
| git commit -m "馃攧 Auto-update BTC data - $(date +'%Y-%m-%d %H:%M:%S UTC')" | |
| git push origin main --force | |
| - name: Set up Docker Buildx | |
| if: steps.git-check.outputs.changes == 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| if: steps.git-check.outputs.changes == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GIT_PASSWORD }} | |
| - name: Get current date | |
| id: date | |
| run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
| - name: Build and push data image | |
| if: steps.git-check.outputs.changes == 'true' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/btc-rpc:latest | |
| ghcr.io/${{ github.repository_owner }}/btc-rpc:${{ steps.date.outputs.date }}_${{ github.run_number }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |