-
-
Notifications
You must be signed in to change notification settings - Fork 40
75 lines (68 loc) · 2.41 KB
/
Copy pathconvert.yml
File metadata and controls
75 lines (68 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Convert Videos to GIFs
on:
push:
paths:
- 'previews/**/videos/*.mp4'
- 'previews/**/videos/*.mov'
branches:
- dev
workflow_dispatch:
jobs:
convert:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache FFmpeg
id: cache-ffmpeg
uses: actions/cache@v3
with:
path: /usr/bin/ffmpeg
key: ${{ runner.os }}-ffmpeg
- name: Install FFmpeg
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: sudo apt-get update && sudo apt-get install -y ffmpeg
- name: Convert videos to GIFs
id: convert
run: |
found_videos=false
for video in previews/**/videos/*.{mp4,mov}; do
if [[ -f "$video" ]]; then
base_dir="$(dirname "$(dirname "$video")")"
output_dir="${base_dir}/gifs"
mkdir -p "$output_dir"
filename=$(basename "$video")
filename_noext="${filename%.*}"
output_gif="${output_dir}/${filename_noext}.gif"
# Only convert if GIF doesn't exist
if [[ ! -f "$output_gif" ]]; then
found_videos=true
echo "Converting $video to GIF..."
ffmpeg -i "$video" \
-vf "fps=15,scale=320:-1:flags=lanczos" \
-c:v gif \
"$output_gif"
else
echo "Skipping $video - GIF already exists"
fi
fi
done
echo "found_videos=$found_videos" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.convert.outputs.found_videos == 'true'
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore: convert videos to GIFs"
title: "Convert videos to GIFs"
body: "Automatically converted video previews to GIF format"
branch: video-to-gif
delete-branch: true
# TODO: Fix this
# - name: Enable Auto-Merge
# if: steps.convert.outputs.found_videos == 'true' && steps.create-pr.outputs.pull-request-number != ''
# uses: peter-evans/enable-pull-request-automerge@v2
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }}
# merge-method: squash