-
-
Notifications
You must be signed in to change notification settings - Fork 39
72 lines (65 loc) · 2.45 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
71
72
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 }}