-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (64 loc) · 2.19 KB
/
build_and_push.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
name: Build and Upload
on:
workflow_dispatch: # This allows you to manually trigger the workflow
release:
types: [published] # This triggers the workflow when a release is published
jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y git curl u-boot-tools ca-certificates gnupg zip
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x' # Set up the Python version you need
- name: Run build script
run: |
chmod +x ./build_image.sh
bash ./build_image.sh desktop
- name: Get Release Info
id: get-release-info
uses: actions/github-script@v5
with:
script: |
let uploadUrl = 0;
try {
const release = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
uploadUrl = release.data.id;
} catch (error) {
console.log('Error fetching latest release: ', error.message);
}
return uploadUrl;
- name: Print release upload URL
run: echo "Upload URL is ${{ steps.get-release-info.outputs.result }}"
- name: Upload Update File Parts to Release
uses: actions/github-script@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const fs = require('fs');
const path = require('path');
const directory = './build';
const files = fs.readdirSync(directory);
for (const file of files) {
if (file.startsWith('update.z')) {
const filePath = path.join(directory, file);
console.log(`Uploading ${file}...`);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ steps.get-release-info.outputs.result }},
name: file,
data: fs.readFileSync(filePath)
});
}
}