name: Rebuild video release assets on: workflow_dispatch: inputs: release_tag: description: "Release tag holding the master video" required: true default: video-assets-v1 source_asset: description: "Filename of the master asset to transcode from" required: true default: video4k.mkv permissions: contents: write jobs: transcode: runs-on: ubuntu-latest strategy: fail-fast: false matrix: resolution: [480, 720, 1080, 2160] steps: - name: Install ffmpeg run: sudo apt-get update && sudo apt-get install -y ffmpeg - name: Download master asset env: GH_TOKEN: ${{ github.token }} run: | gh release download "${{ inputs.release_tag }}" \ --repo "${{ github.repository }}" \ --pattern "${{ inputs.source_asset }}" \ --output source.input - name: Transcode run: | ffmpeg -y -i source.input -vf "scale=-2:${{ matrix.resolution }}" \ -c:v libx264 -preset medium -crf 18 \ -c:a aac -b:a 192k \ -movflags +faststart \ "video-${{ matrix.resolution }}p.mp4" - name: Verify output resolution run: | set -eu height=$(ffprobe -v error -select_streams v:0 \ -show_entries stream=height -of csv=p=0 "video-${{ matrix.resolution }}p.mp4") echo "video-${{ matrix.resolution }}p.mp4 -> height=${height}" [ "$height" = "${{ matrix.resolution }}" ] || { echo "::error::expected height ${{ matrix.resolution }}, got $height"; exit 1; } - name: Upload transcoded asset env: GH_TOKEN: ${{ github.token }} run: | gh release upload "${{ inputs.release_tag }}" \ "video-${{ matrix.resolution }}p.mp4" \ --repo "${{ github.repository }}" --clobber # Video content can change (a re-transcode uploaded to the same asset # URLs) without any git diff at all, so there's nothing for Drone's own # push-triggered webhook (Settings > Webhooks in this repo) to detect. # Rather than talking to Drone directly (a separate token/API to # manage), just bump the marker comment at the top of .drone.yml and # push it - .drone.yml is already in every pipeline's paths filter, so # this is a normal push that flows through the exact same webhook the # Dockerfile/scripts-triggered builds already use. trigger-drone: needs: transcode runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: ref: master - name: Bump video refresh marker and push run: | sed -i "s/# Last video refresh:.*/# Last video refresh: $(date -u +%Y-%m-%dT%H:%M:%SZ)/" .drone.yml git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add .drone.yml git commit -m "Bump video refresh marker to trigger a Drone rebuild" git push origin master