From 709035c7c4c2c8368b10cc60466a9f2dacf640f1 Mon Sep 17 00:00:00 2001 From: Maxython Date: Tue, 26 Nov 2024 09:45:39 +0000 Subject: [PATCH] index.js: migration from lunar to oracular --- .github/workflows/test.yml | 2 +- README.md | 2 +- index.js | 26 +++++++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 752ae4d..abc0c43 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ on: jobs: debug1: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 name: Check commands steps: - uses: actions/checkout@v4 diff --git a/README.md b/README.md index dbcb1bc..96b0837 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Example: ```yml jobs: example: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 name: Example steps: - uses: actions/checkout@v4 diff --git a/index.js b/index.js index 30e4c5a..3e0ae6b 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,12 @@ // Running a script that sets everything up const exec = require('@actions/exec'); -const core = require('@actions/core') +const core = require('@actions/core'); + +function error(message) { + core.setFailed(message); + process.exit(1); +} async function installPkg(pkgname) { let attempts = 0; @@ -12,8 +17,7 @@ async function installPkg(pkgname) { break; } catch (error) { if (attempts > 3) { - core.setFailed("Something went wrong :/"); - process.exit(1); + error("Something went wrong :/"); } attempts += 1; continue; @@ -22,10 +26,22 @@ async function installPkg(pkgname) { } async function start() { + let myOutput = ''; + await exec.exec("lsb_release", ["-r"], { + listeners: { + stdout: (data) => { + myOutput += data.toString(); + } + } + }); + if (myOutput.split(" ")[-1].split(".")[0] != "24") { + error("old version of ubuntu, must be version 24 of ubuntu"); + } + await installPkg("libarchive-tools"); - await exec.exec("sudo su -c \"echo 'deb http://archive.ubuntu.com/ubuntu/ lunar universe' > /etc/apt/sources.list.d/lunar.list\""); - await exec.exec("sudo su -c \"echo 'deb-src http://archive.ubuntu.com/ubuntu/ lunar universe' >> /etc/apt/sources.list.d/lunar.list\""); + await exec.exec("sudo su -c \"echo 'deb http://archive.ubuntu.com/ubuntu/ oracular universe' > /etc/apt/sources.list.d/oracular.list\""); + await exec.exec("sudo su -c \"echo 'deb-src http://archive.ubuntu.com/ubuntu/ oracular universe' >> /etc/apt/sources.list.d/oracular.list\""); await installPkg("pacman-package-manager"); }