Download Firmware #179
This file contains 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: Download Firmware | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Runs every day at midnight | |
# You can also trigger this workflow manually or on other events | |
workflow_dispatch: | |
jobs: | |
download-and-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Get Latest Release | |
id: get-release | |
run: | | |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/skot/ESP-Miner/releases/latest) | |
RELEASE_TAG=$(echo $LATEST_RELEASE | jq -r .tag_name) | |
echo "::set-output name=tag_name::$RELEASE_TAG" | |
- name: Download ESP Miner Binary | |
run: | | |
ESP_MINER_URL=$(curl -s https://api.github.com/repos/skot/ESP-Miner/releases/latest | jq -r '.assets[] | select(.name == "esp-miner.bin") | .browser_download_url') | |
if [ -n "$ESP_MINER_URL" ]; then | |
wget -O firmware/esp-miner.bin $ESP_MINER_URL | |
else | |
echo "ESP Miner binary not found, skipping download." | |
fi | |
- name: Download WWW Binary | |
run: | | |
WWW_BIN_URL=$(curl -s https://api.github.com/repos/skot/ESP-Miner/releases/latest | jq -r '.assets[] | select(.name == "www.bin") | .browser_download_url') | |
if [ -n "$WWW_BIN_URL" ]; then | |
wget -O firmware/www.bin $WWW_BIN_URL | |
else | |
echo "WWW binary not found, skipping download." | |
fi | |
- name: Update HTML with Version | |
run: | | |
sed -i 's|<label><input type="radio" name="type" value="update" /> All Bitaxe just update</label>|<label><input type="radio" name="type" value="update" /> All Bitaxe just update - Version ${{ steps.get-release.outputs.tag_name }}</label>|g' index.html | |
- name: Check for Changes | |
id: check-changes | |
run: | | |
git diff --exit-code || echo "::set-output name=changes_detected::true" | |
- name: Commit and Push | |
if: steps.check-changes.outputs.changes_detected == 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add firmware/esp-miner.bin firmware/www.bin index.html | |
git commit -m "Update firmware binaries to ${{ steps.get-release.outputs.tag_name }}" | |
git push --set-upstream origin HEAD:master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |