From dbbbd78ed87addbdff390866a58e6897ba8a3955 Mon Sep 17 00:00:00 2001 From: Neilpang Date: Sun, 10 Dec 2023 16:00:44 +0000 Subject: [PATCH] Update from base builder --- .github/FUNDING.yml | 12 ++++++ .github/tpl/README.tpl.md | 7 ++++ .github/workflows/manual.yml | 13 +++---- .github/workflows/readme.yml | 48 ++++++++++++++++++++++++ build.sh | 73 ++++++++++++++++++++++++++++-------- 5 files changed, 131 insertions(+), 22 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/tpl/README.tpl.md create mode 100644 .github/workflows/readme.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..359f239 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: vmactions +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/tpl/README.tpl.md b/.github/tpl/README.tpl.md new file mode 100644 index 0000000..9966797 --- /dev/null +++ b/.github/tpl/README.tpl.md @@ -0,0 +1,7 @@ + + +[![Build](https://github.com/vmactions/{{VM_OS_NAME}}-builder/actions/workflows/build.yml/badge.svg)](https://github.com/vmactions/{{VM_OS_NAME}}-builder/actions/workflows/build.yml) + +Latest: {{LATEST_TAG}} + + diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml index f70ed4c..df04242 100644 --- a/.github/workflows/manual.yml +++ b/.github/workflows/manual.yml @@ -7,19 +7,18 @@ jobs: build: runs-on: ubuntu-22.04 env: - RELEASE: "11.4" DEBUG: 1 - VM_OS_NAME: solaris NGROK_TOKEN : ${{ secrets.NGROK_TOKEN }} SEC_VBOX : ${{ secrets.SEC_VBOX }} steps: - uses: actions/checkout@v4 - - uses: vmactions/cf-tunnel@v0 + - name: Creating web console + uses: vmactions/cf-tunnel@v0 id: tunnel with: protocol: http port: 8000 - - name: Run establish a ngrok tunnel + - name: Run vnc tunnel id: test uses: vmactions/ngrok-tunnel@v0.0.1 with: @@ -28,16 +27,16 @@ jobs: - name: Sleep run: | for i in $(seq 1 10) ; do echo $i; sleep 1; done + latest=$(cat $(ls conf/solaris-*.conf | tail -1) | grep VM_RELEASE | cut -d = -f 2) echo "please loging to ssh below, and run:" echo "=============================" - echo "bash build.sh conf/solaris-$RELEASE.conf" + echo "bash build.sh conf/solaris-$latest.conf" echo "=============================" touch /tmp/keepalive - uses: neilpang/debugger-action@master -# - run: | -# bash build.sh conf/solaris-$RELEASE.conf + diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml new file mode 100644 index 0000000..18b313b --- /dev/null +++ b/.github/workflows/readme.yml @@ -0,0 +1,48 @@ +name: "Update Readme" +on: + workflow_dispatch: + push: + branches: + - 'main' + paths: + - '.github/tpl/*' + - '.github/data/*' + - '.github/workflows/readme.yml' + + release: + types: [ published ] + + +jobs: + readme: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get latest release + id: get-latest-release + uses: InsonusK/get-latest-release@v1.0.1 + with: + myToken: ${{ github.token }} + view_top: 1 + + - name: Using main branch + run: | + git switch main || (git fetch --all && git checkout -b main origin/main) + echo "LATEST_MAJOR=$(echo ${{ steps.get-latest-release.outputs.tag_name }} | cut -d . -f 1)" >> $GITHUB_ENV + echo "LATEST_TAG=${{ steps.get-latest-release.outputs.tag_name }}" >> $GITHUB_ENV + + - name: Update the readme.md + uses: vmactions/render@v0.0.1 + with: + datafile: .github/data/datafile.ini + files: | + .github/tpl/README.tpl.md : README.md + + - uses: EndBug/add-and-commit@v9 + with: + message: "Update version to ${{ steps.get-latest-release.outputs.tag_name }}" + pull: '--rebase --autostash ' + add: | + README.md + diff --git a/build.sh b/build.sh index 35bb6a8..89be67e 100644 --- a/build.sh +++ b/build.sh @@ -72,22 +72,53 @@ if ! $vmsh clearVM $osname; then echo "vm does not exists" fi -$vmsh createVM $VM_ISO_LINK $osname $ostype $sshport - - -sleep 2 +if [ "$VM_ISO_LINK" ]; then + $vmsh createVM $VM_ISO_LINK $osname $ostype $sshport + + sleep 2 + + if [ -e "hooks/installOpts.sh" ]; then + echo "hooks/installOpts.sh" + cat "hooks/installOpts.sh" + . "hooks/installOpts.sh" + else + $vmsh processOpts $osname "$opts" + + echo "sleep 60 seconds. just wait" + sleep 60 + + if $vmsh isRunning $osname; then + if ! $vmsh shutdownVM $osname; then + echo "shutdown error" + fi + if ! $vmsh destroyVM $osname; then + echo "destroyVM error" + fi + fi + fi -$vmsh processOpts $osname "$opts" + while $vmsh isRunning $osname; do + sleep 5 + done -echo "sleep 180 seconds. just wait" -sleep 180 +elif [ "$VM_VHD_LINK" ]; then + if [ ! -e "$osname.qcow2.xz" ]; then + $vmsh download "$VM_VHD_LINK" $osname.qcow2.xz + fi -$vmsh shutdownVM $osname + if [ ! -e "$osname.qcow2" ]; then + xz -d -T 0 --verbose "$osname.qcow2.xz" + fi -$vmsh destroyVM $osname + $vmsh createVMFromVHD $osname $ostype $sshport + sleep 5 +else + echo "no VM_ISO_LINK or VM_VHD_LINK, can not build." + exit 1 +fi $vmsh startVM $osname @@ -96,14 +127,21 @@ sleep 2 ############################################### - - -waitForText "$VM_LOGIN_TAG" +if [ -e "hooks/waitForLoginTag.sh" ]; then + echo "hooks/waitForLoginTag.sh" + cat "hooks/waitForLoginTag.sh" + . "hooks/waitForLoginTag.sh" +else + waitForText "$VM_LOGIN_TAG" +fi sleep 3 -inputKeys "string root; enter; sleep 1; string $VM_ROOT_PASSWORD ; enter" - +inputKeys "string root; enter; sleep 1;" +if [ "$VM_ROOT_PASSWORD" ]; then + inputKeys "string $VM_ROOT_PASSWORD ; enter" +fi +inputKeys "enter" sleep 2 @@ -241,7 +279,12 @@ else $vmsh addSSHAuthorizedKeys $osname-$VM_RELEASE-id_rsa.pub $vmsh startVM $osname $vmsh waitForVMReady $osname - ssh $osname sh <<<"$VM_INSTALL_CMD $VM_RSYNC_PKG $VM_SSHFS_PKG" + if [ "$VM_RSYNC_PKG" ]; then + ssh $osname sh <<<"$VM_INSTALL_CMD $VM_RSYNC_PKG" + fi + if [ "$VM_SSHFS_PKG" ]; then + ssh $osname sh <<<"$VM_INSTALL_CMD $VM_SSHFS_PKG" + fi fi