Update OTA Repository #1
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: Update OTA Repository | |
on: | |
workflow_run: | |
workflows: ["build"] | |
branches: [develop] | |
types: | |
- completed | |
jobs: | |
update-ota: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout OTA Updates Repository | |
uses: actions/checkout@v4 | |
with: | |
repository: 'doudar/OTAUpdates' | |
token: ${{ secrets.OTA_TOKEN }} # Use your secret token here | |
path: 'OTAUpdates' | |
- name: Get Latest Release from SmartSpin2k | |
id: get-release | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const repo = { | |
owner: 'doudar', | |
repo: 'SmartSpin2k', | |
}; | |
const response = await github.rest.repos.getLatestRelease(repo); | |
const assets = response.data.assets.filter(asset => asset.name.includes('.bin.zip')); | |
if (assets.length === 0) { | |
core.setFailed('No .bin.zip assets found in the latest release.'); | |
return; // This stops the script execution if no assets are found | |
} | |
const url = assets[0].browser_download_url; | |
const tag_name = response.data.tag_name; | |
core.setOutput('url', url); | |
core.setOutput('tag_name', tag_name); | |
- name: Download Artifacts | |
if: steps.get-release.outputs.url | |
run: | | |
curl -L "${{ steps.get-release.outputs.url }}" -o firmware.zip | |
mkdir firmware/ | |
unzip firmware.zip -d firmware | |
ls -R firmware # List files for diagnostics | |
- name: Process Version and Files | |
run: | | |
VERSION_TAG="${{ steps.get-release.outputs.tag_name }}" | |
PROCESSED_VERSION="${VERSION_TAG%-*}" | |
echo $PROCESSED_VERSION > version.txt | |
ls | |
# Copy the .bin files directly as they are now confirmed to be in the 'firmware' directory | |
cp ./firmware/*.bin ./ | |
# Ensure we're listing files here for a final check, remove in the final workflow | |
ls -la | |
working-directory: ./OTAUpdates | |
- name: Commit and Push Updates to OTAUpdates Repository | |
uses: EndBug/add-and-commit@v9 | |
with: | |
default_author: github_actions | |
message: 'Update firmware and LittleFS with version ${{ steps.get-release.outputs.tag_name }}' | |
add: './*' | |
cwd: './OTAUpdates' | |
pull_strategy: 'NO-PULL' | |
push: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.OTA_TOKEN }} |