Skip to content

Update OTA Repository #4

Update OTA Repository

Update OTA Repository #4

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@v2
with:
repository: 'doudar/OTAUpdates'
token: ${{ secrets.OTA_TOKEN }}
path: 'OTAUpdates'
- name: Get Latest Release from SmartSpin2k
id: get-release
uses: actions/github-script@v5
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
unzip firmware.zip -d firmware
- name: Process Version and Files
run: |
VERSION_TAG="${{ steps.get-release.outputs.tag_name }}"
PROCESSED_VERSION="${VERSION_TAG%-*}"
echo $PROCESSED_VERSION > version.txt
cp firmware/*.bin ./
working-directory: ./OTAUpdates
- name: Commit and Push Updates to OTAUpdates Repository
uses: EndBug/add-and-commit@v7
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 }}