Files
auto-update/.gitea/workflows/zellij_update.yml

81 lines
3.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 工作流名称
name: Zellij 最新版本自动更新
# 触发器配置
on:
# 1. 定时触发 (Cron 表达式: 每天 UTC 时间 00:00 运行)
schedule:
- cron: '0 0 * * *'
# 2. 允许手动通过 Gitea UI 触发
workflow_dispatch:
# 定义 Job
jobs:
update_zellij_binary:
# 运行环境
runs-on: ubuntu-latest
steps:
- name: 检出仓库代码 (Checkout Repository)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 设置 Git 用户信息 (Set up Git user)
run: |
git config user.name "Gitea Actions Bot"
git config user.email "gitea-actions[bot]@example.com"
- name: 定义变量 (Define Variables)
id: vars
run: |
# 最新版本的下载链接
RELEASE_URL="https://github.com/zellij-org/zellij/releases/latest/download/zellij-x86_64-unknown-linux-musl.tar.gz"
# 仓库内的目标目录
TARGET_DIR="app/zellij"
echo "RELEASE_URL=$RELEASE_URL" >> $GITHUB_ENV
echo "TARGET_DIR=$TARGET_DIR" >> $GITHUB_ENV
- name: 下载、解压并放置 Zellij 二进制文件 (Download, Extract, and Place Zellij Binary)
run: |
# 确保目标目录存在
mkdir -p ${{ env.TARGET_DIR }}
echo "开始下载最新的 Zellij 二进制文件..."
# 使用 curl 下载文件到临时位置
curl -sSL -o zellij.tar.gz "${{ env.RELEASE_URL }}"
# 解压文件,会释放出一个名为 'zellij' 的二进制文件
tar -xzf zellij.tar.gz
# 将二进制文件移动到指定的目录,并重命名为 'zellij'
mv zellij ${{ env.TARGET_DIR }}/zellij
# 赋予执行权限
chmod +x ${{ env.TARGET_DIR }}/zellij
# 清理下载的压缩包
rm zellij.tar.gz
- name: 检查更改并创建提交 (Check for Changes and Commit)
id: commit
run: |
# 检查目标文件是否发生了变化
if git diff --exit-code ${{ env.TARGET_DIR }}/zellij ; then
echo "status=no-change" >> $GITHUB_OUTPUT
echo "::notice file=${{ env.TARGET_DIR }}/zellij::Zellij 二进制文件没有变化,跳过提交。"
else
echo "status=changed" >> $GITHUB_OUTPUT
git add ${{ env.TARGET_DIR }}/zellij
# 使用 --allow-empty 确保即使文件内容不变,也能提交(如果需要,但这里我们使用 diff 避免空提交)
git commit -m "chore(deps): 自动更新 Zellij 到最新版本"
echo "::notice file=${{ env.TARGET_DIR }}/zellij::发现新版本 Zellij已创建提交。"
fi
- name: 推送更改到 Gitea (Push Changes to Gitea)
# 仅当检测到文件变化且有新提交时才推送
if: steps.commit.outputs.status == 'changed'
run: |
# 因为 actions/checkout 已经设置了内置 token 的凭证,所以可以直接执行 git push
git push