-
-
Notifications
You must be signed in to change notification settings - Fork 38
70 lines (60 loc) · 2.27 KB
/
update_ota_repo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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 > OTAUpdates/version.txt
cp firmware/*.bin OTAUpdates/
# This assumes the archive directly contains firmware.bin and littlefs.bin
- name: Commit and Push Updates to OTAUpdates Repository
uses: EndBug/add-and-commit@v7
with:
repository: 'doudar/OTAUpdates'
default_author: github_actions
message: 'Update firmware and LittleFS with version ${{ steps.get-release.outputs.tag_name }}'
add: 'OTAUpdates/*'
cwd: 'OTAUpdates'
pull_strategy: 'NO-PULL'
push: true
env:
GITHUB_TOKEN: ${{ secrets.OTA_TOKEN }}