Run AppImage #56
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run AppImage | |
on: | |
workflow_dispatch: | |
inputs: | |
manual-run: | |
description: '测试远程调用' | |
required: true | |
default: 'true' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Create Cache Directory | |
run: mkdir -p ./apt-cache/*.deb | |
- name: Cache APT packages | |
uses: actions/cache@v3 | |
with: | |
path: ./apt-cache/*.deb | |
key: apt-cache-${{ runner.os }} | |
restore-keys: | | |
apt-cache-${{ runner.os }}- | |
- name: Install GUI Dependency | |
run: | | |
if [ -z "$(ls -A ./apt-cache/*.deb 2>/dev/null)" ]; then | |
echo "Downloading APT packages..." | |
sudo apt-get update | |
sudo apt-get install -y --download-only $(cat apt-packages.txt) # 只下载依赖 | |
sudo cp /var/cache/apt/archives/*.deb ./apt-cache/ # 拷贝到缓存文件夹 | |
else | |
echo "Using cached APT packages." | |
fi | |
for deb in $DEB_DIR*.deb; do | |
if [ -f "$deb" ]; then | |
sudo apt-get --download-only install $(dpkg -I "$deb" | grep '^ Depends:' | cut -d ' ' -f 2- | tr '\n' ',') | |
fi | |
done | |
ls ./apt-cache/ | |
- name: Install APT packages | |
run: | | |
echo "Installing APT packages..." | |
for deb in ./apt-cache/*.deb; do | |
if [ -f "$deb" ]; then # 确保是文件而不是目录 | |
echo $deb | |
sudo dpkg -i "$deb" || true | |
fi | |
done | |
# 解决剩余的依赖问题 | |
sudo apt-get install -f -y | |
- name: Configure locales | |
run: | | |
echo "配置 locales" | |
sudo locale-gen en_GB.UTF-8 | |
sudo dpkg-reconfigure locales | |
- name: Setup Xauthority | |
run: | | |
if [ ! -f $HOME/.Xauthority ]; then | |
touch $HOME/.Xauthority | |
xauth nlist $DISPLAY | xauth -f $HOME/.Xauthority nmerge - | |
else | |
echo ".Xauthority 已配置,跳过配置步骤。" | |
fi | |
- name: Start Xvfb | |
run: | | |
Xvfb :99 -screen 0 1024x768x24 & | |
echo "DISPLAY=:99" >> $GITHUB_ENV | |
- name: Start AT-SPI Registry | |
run: | | |
echo "Starting AT-SPI Registry" | |
export XDG_SESSION_COOKIE=$(xauth list | grep .$DISPLAY | cut -d' ' -f1) | |
dbus-launch --exit-with-session | |
echo "AT-SPI Registry started" | |
- name: Cache AppImage | |
uses: actions/cache@v3 | |
with: | |
path: appimage.AppImage | |
key: appimage-cache-${{ runner.os }} | |
restore-keys: | | |
appimage-cache-${{ runner.os }}- | |
- name: Download AppImage | |
run: | | |
if [ ! -f appimage.AppImage ]; then | |
echo "下载 AppImage" | |
wget https://github.com/Snapmaker/OrcaSlicer/releases/download/nightlybuild/Snapmaker_Orca_Engine_Linux_V0.0.1.AppImage -O appimage.AppImage | |
chmod 777 appimage.AppImage | |
else | |
echo "AppImage 已下载,跳过下载步骤。" | |
fi | |
- name: Copy Config | |
run: | | |
mkdir -p ~/.config/Snapmaker_Orca | |
cp Snapmaker_Orca.conf ~/.config/Snapmaker_Orca/Snapmaker_Orca.conf | |
- name: Run AppImage | |
run: | | |
./appimage.AppImage /home/runner/work/Snapmaker_Engine/Snapmaker_Engine/3DBenchy.3mf | |
cd /home/runner/work/Snapmaker_Engine/Snapmaker_Engine/ | |
ls -a | |
env: | |
DISPLAY: ":99" | |
# debug | |
# - name: Run AppImage | |
# run: | | |
# ./appimage.AppImage /home/runner/work/Snapmaker_Engine/Snapmaker_Engine/3DBenchy.3mf & | |
# APPIMAGE_PID=$! | |
# echo "AppImage is running with PID $APPIMAGE_PID" | |
# env: | |
# DISPLAY: ":99" | |
# - name: Capture Screenshots | |
# run: | | |
# for i in {1..10}; do | |
# sleep 5 # Capture a screenshot every 5 seconds | |
# import -display :99 -window root /home/runner/work/screenshot_$i.png | |
# echo "Screenshot $i captured" | |
# done | |
# | |
# - name: Gracefully stop the AppImage | |
# run: | | |
# if [ -n "$APPIMAGE_PID" ]; then | |
# kill $APPIMAGE_PID | |
# else | |
# echo "PID not found, cannot kill the AppImage process." | |
# fi | |
# - name: Upload Screenshots | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: Screenshots | |
# path: /home/runner/work/screenshot_*.png |