Skip to content

Commit

Permalink
add: error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ionut-cmd committed Dec 12, 2023
1 parent dc2926b commit a7607e3
Showing 1 changed file with 73 additions and 62 deletions.
135 changes: 73 additions & 62 deletions .github/workflows/create-demo-app-debs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ jobs:
- name: Build ARM64 Server
run: aarch64-linux-gnu-gcc -o server_arm64 debian-brski/brski-demo-app-deb/opt/demo-server/server.c -L/libmicrohttpd/src/microhttpd/.libs -L/zlib -lmicrohttpd -lz -static

- name: Set execute permission on ARM64 Server Binary
run: chmod +x server_arm64

- name: Upload server binary as an artifact
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -93,6 +90,9 @@ jobs:
name: server-arm64-binary
path: debian-brski/brski-demo-app-deb/opt/demo-server/

- name: Set execute permission on ARM64 Server Binary
run: sudo chmod +x debian-brski/brski-demo-app-deb/opt/demo-server/server_arm64

- name: Build ARM64 Debian Package
run: dpkg-deb --build debian-brski/brski-demo-app-deb brski-demo-app-deb_arm64.deb

Expand Down Expand Up @@ -175,38 +175,45 @@ jobs:
const fs = require('fs');
const path = './brski-demo-app-deb_arm64.deb';
// Check if the file exists
if (!fs.existsSync(path)) {
throw new Error("File not found: " + path);
}
const { owner, repo } = context.repo;
const release_id = ${{ env.RELEASE_ID }};
const asset_name = 'brski-demo-app-deb_arm64.deb';
// Delete existing asset with the same name
const assets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id });
const existingAsset = assets.data.find(asset => asset.name === asset_name);
if (existingAsset) {
await github.rest.repos.deleteReleaseAsset({
owner,
repo,
asset_id: existingAsset.id
try {
// Check if the file exists
if (!fs.existsSync(path)) {
throw new Error("File not found: " + path);
}
const { owner, repo } = context.repo;
const release_id = process.env.RELEASE_ID;
const asset_name = 'brski-demo-app-deb_arm64.deb';
// Delete existing asset with the same name
const assets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id });
const existingAsset = assets.data.find(asset => asset.name === asset_name);
if (existingAsset) {
await github.rest.repos.deleteReleaseAsset({
owner,
repo,
asset_id: existingAsset.id
});
}
// Upload the new asset
const contentLength = fs.statSync(path).size;
const headers = { 'content-type': 'application/octet-stream', 'content-length': contentLength };
const uploadUrl = `https://uploads.github.com/repos/${owner}/${repo}/releases/${release_id}/assets?name=${asset_name}`;
const asset = fs.readFileSync(path);
await github.rest.repos.uploadReleaseAsset({
headers,
name: asset_name,
data: asset,
url: uploadUrl
});
} catch (error) {
console.error(`Error uploading ${asset_name}, ${error}`);
}
env:
RELEASE_ID: ${{ env.RELEASE_ID }}

// Upload the new asset
const contentLength = fs.statSync(path).size;
const headers = { 'content-type': 'application/octet-stream', 'content-length': contentLength };
const uploadUrl = `https://uploads.github.com/repos/${owner}/${repo}/releases/${release_id}/assets?name=${asset_name}`;
const asset = fs.readFileSync(path);
await github.rest.repos.uploadReleaseAsset({
headers,
name: asset_name,
data: asset,
url: uploadUrl
});


- name: Upload AMD64 Debian Package to Release
Expand All @@ -217,35 +224,39 @@ jobs:
const fs = require('fs');
const path = './brski-demo-app-deb-x86_64.deb';
// Check if the file exists
if (!fs.existsSync(path)) {
throw new Error("File not found: " + path);
}
const { owner, repo } = context.repo;
const release_id = ${{ env.RELEASE_ID }};
const asset_name = 'brski-demo-app-deb-x86_64.deb';
// Delete existing asset with the same name
const assets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id });
const existingAsset = assets.data.find(asset => asset.name === asset_name);
if (existingAsset) {
await github.rest.repos.deleteReleaseAsset({
owner,
repo,
asset_id: existingAsset.id
try {
// Check if the file exists
if (!fs.existsSync(path)) {
throw new Error("File not found: " + path);
}
const { owner, repo } = context.repo;
const release_id = process.env.RELEASE_ID;
const asset_name = 'brski-demo-app-deb-x86_64.deb';
// Delete existing asset with the same name
const assets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id });
const existingAsset = assets.data.find(asset => asset.name === asset_name);
if (existingAsset) {
await github.rest.repos.deleteReleaseAsset({
owner,
repo,
asset_id: existingAsset.id
});
}
// Upload the new asset
const contentLength = fs.statSync(path).size;
const headers = { 'content-type': 'application/octet-stream', 'content-length': contentLength };
const uploadUrl = `https://uploads.github.com/repos/${owner}/${repo}/releases/${release_id}/assets?name=${asset_name}`;
const asset = fs.readFileSync(path);
await github.rest.repos.uploadReleaseAsset({
headers,
name: asset_name,
data: asset,
url: uploadUrl
});
} catch (error) {
console.error(`Error uploading ${asset_name}, ${error}`);
}
// Upload the new asset
const contentLength = fs.statSync(path).size;
const headers = { 'content-type': 'application/octet-stream', 'content-length': contentLength };
const uploadUrl = `https://uploads.github.com/repos/${owner}/${repo}/releases/${release_id}/assets?name=${asset_name}`;
const asset = fs.readFileSync(path);
await github.rest.repos.uploadReleaseAsset({
headers,
name: asset_name,
data: asset,
url: uploadUrl
});

0 comments on commit a7607e3

Please sign in to comment.