Skip to content

v0.11

v0.11 #2

Workflow file for this run

name: ci
on: [push, pull_request] # 当代码被推送或拉取请求时触发工作流
jobs:
build:
runs-on: ubuntu-latest # 在最新的 Ubuntu 环境中运行工作流
permissions:
contents: write # 给予工作流写入仓库的权限
steps:
- name: Clone repository # 步骤名称
uses: actions/checkout@v4 # 使用 actions/checkout 动作来克隆仓库
- name: Make youtube-dl executable
run: chmod +x ./bin/youtube-dl # 给予执行权限
- name: Install Git LFS # 使用LFS 上传大文件
run: |
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install
- name: Track large video files # 跟踪 mp4 文件
run: |
git lfs track "*.mp4"
- name: Configure Git user
run: |
git config --local user.email "[email protected]" # 配置 Git 用户邮箱
git config --local user.name "Huterox" # 配置 Git 用户名
- name: Set Git remote URL
env: # 设置环境变量
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} # 设置远程仓库 URL
- name: Pull latest changes
run: git pull --rebase # 拉取最新的更改并变基
- name: Download video with retry
run: |
max_retries=3
retry_count=0
download_success=false
while [ $retry_count -lt $max_retries ] && [ "$download_success" == "false" ]; do
./bin/youtube-dl --config-location config.txt # 尝试下载视频
if [ $? -eq 0 ]; then # 如果下载成功
download_success=true
else
retry_count=$((retry_count+1))
echo "Download attempt $retry_count failed. Retrying in 5 seconds..." # 打印重试信息
sleep 5 # 等待5秒
fi
done
if [ "$download_success" == "false" ]; then
echo "Failed to download video after $max_retries attempts." # 打印失败信息
exit 1
fi
- name: Commit and push changes
run: |
git add . # 添加所有更改
git commit -m "download youtube video" # 提交更改
git push || echo "Push failed, possibly due to branch protection or lack of permission." # 推送更改,如果失败打印信息
- name: Error handling
if: failure() # 如果前面的步骤失败
run: |
echo "An error occurred. Check the logs for details." # 打印错误信息