Add comment to video with detailed timestamps #21
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: Build video | |
on: | |
issues: | |
types: | |
- reopened | |
- opened | |
jobs: | |
build_video: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./ | |
steps: | |
- name: Set up Git repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
architecture: 'x64' | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Get Oyez link | |
id: get_oyez_link | |
uses: actions/github-script@v6 | |
env: | |
ISSUE_OWNER: ${{ github.event.issue.user.login }} | |
ISSUE_BODY: ${{ github.event.issue.body }} | |
with: | |
result-encoding: string | |
script: | | |
const oyezLinkPattern = /https:\/\/www\.oyez\.org\/cases\/\d{4}\/[\w-]+/; | |
if(process.env.ISSUE_OWNER !== context.repo.owner) { | |
throw new Error("Issue owner is not the repo owner."); | |
} | |
const linkMatch = process.env.ISSUE_BODY.match(oyezLinkPattern); | |
if(linkMatch) { | |
return linkMatch[0]; | |
} else { | |
throw new Error("The issue body does not contain a valid oyez link."); | |
} | |
- name: Install dependencies | |
run: | | |
sudo apt install -y sox libsox-fmt-mp3 ffmpeg | |
pip install requests sox b2sdk pillow google-api-python-client google-auth google-auth-oauthlib | |
npm install puppeteer | |
mkdir json thumbnails frames videos | |
- name: Fetch and preprocess Oyez data | |
run: | | |
python preprocess.py ${{ steps.get_oyez_link.outputs.result }} | |
- name: Node screenshots | |
run: | | |
python -m http.server 8002 & | |
node screenshot.js | |
- name: Encode video | |
run: | | |
python build-video.py | |
- name: Upload video | |
env: | |
B2_APP_KEY: ${{ secrets.B2_APP_KEY }} | |
B2_APP_KEY_ID: ${{ secrets.B2_APP_KEY_ID }} | |
YT_DEV_KEY: ${{ secrets.YT_DEV_KEY }} | |
run: | | |
curl --retry 3 -o credentials.json ${{ secrets.CREDENTIAL_URL }} | |
python upload-video.py | |
# run: | | |
# curl --silent --upload-file thumbnails/63561.png --user f0146955:${{ secrets.ftp_password }} ftp://w008ef9a.kasserver.com | |
# curl --silent --upload-file frames/63561/frame-1.png --user f0146955:${{ secrets.ftp_password }} ftp://w008ef9a.kasserver.com | |
- name: Close issue with a comment from comment.txt | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const commentContent = fs.readFileSync('comment.txt', 'utf8'); | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: commentContent | |
}); | |
await github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
state: 'closed' | |
}); |