Add a post processor for after move #1055
Workflow file for this run
This file contains hidden or 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: CI | |
env: | |
IMAGE_NAME: tubesync | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
- 'test-*' | |
pull_request: | |
branches: | |
- 'main' | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
jobs: | |
info: | |
if: ${{ !cancelled() && 'pull_request' != github.event_name }} | |
runs-on: ubuntu-latest | |
outputs: | |
ffmpeg-date: ${{ steps.jq.outputs.FFMPEG_DATE }} | |
ffmpeg-releases: ${{ steps.ffmpeg.outputs.releases }} | |
ffmpeg-version: ${{ steps.jq.outputs.FFMPEG_VERSION }} | |
lowercase-github-actor: ${{ steps.github-actor.outputs.lowercase }} | |
lowercase-github-repository_owner: ${{ steps.github-repository_owner.outputs.lowercase }} | |
ytdlp-latest-release: ${{ steps.yt-dlp.outputs.latest-release }} | |
ytdlp-releases: ${{ steps.yt-dlp.outputs.releases }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Lowercase github username | |
id: github-actor | |
uses: ./.github/actions/string-case | |
with: | |
string: ${{ github.actor }} | |
- name: Lowercase github repository owner | |
id: github-repository_owner | |
uses: ./.github/actions/string-case | |
with: | |
string: ${{ github.repository_owner }} | |
- name: Retrieve yt-dlp/FFmpeg-Builds releases with GitHub CLI | |
id: ffmpeg | |
uses: ./.github/actions/FFmpeg | |
- name: Retrieve yt-dlp/yt-dlp releases with GitHub CLI | |
id: yt-dlp | |
uses: ./.github/actions/yt-dlp | |
- name: Set outputs with jq | |
id: jq | |
run: | | |
cat >| .ffmpeg.releases.json <<'EOF' | |
${{ steps.ffmpeg.outputs.releases }} | |
EOF | |
mk_delim() { local f='%s_EOF_%d_' ; printf -- "${f}" "$1" "${RANDOM}" ; } ; | |
open_ml_var() { local f=''\%'s<<'\%'s\n' ; printf -- "${f}" "$2" "$1" ; } ; | |
close_ml_var() { local f='%s\n' ; printf -- "${f}" "$1" ; } ; | |
{ | |
var='FFMPEG_DATE' ; | |
delim="$(mk_delim "${var}")" ; | |
open_ml_var "${delim}" "${var}" ; | |
jq_arg='[foreach .[] as $release ([{}, []]; [ .[0] + {($release.commit): ([ $release.date ] + (.[0][($release.commit)] // []) ) }, [ .[1][0] // $release.commit ] ] ; .[0][(.[1][0])] ) ][-1][0]' ; | |
jq -r "${jq_arg}" -- .ffmpeg.releases.json ; | |
close_ml_var "${delim}" "${var}" ; | |
ffmpeg_date="$( jq -r "${jq_arg}" -- .ffmpeg.releases.json )" | |
var='FFMPEG_VERSION' ; | |
delim="$(mk_delim "${var}")" ; | |
open_ml_var "${delim}" "${var}" ; | |
jq_arg='.[]|select(.date == $date)|.versions[]|select(startswith("N-"))' ; | |
jq -r --arg date "${ffmpeg_date}" "${jq_arg}" -- .ffmpeg.releases.json ; | |
close_ml_var "${delim}" "${var}" ; | |
unset -v delim jq_arg var ; | |
} >> "${GITHUB_OUTPUT}" | |
cat -v "${GITHUB_OUTPUT}" | |
rm -v -f .ffmpeg.releases.json | |
test: | |
if: ${{ !cancelled() && ( 'pull_request' != github.event_name || (! github.event.pull_request.draft) ) }} | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pipenv | |
PIPENV_VERBOSITY=64 pipenv install --system --skip-lock | |
- name: Set up Django environment | |
run: | | |
cp -v -p tubesync/tubesync/local_settings.py.example tubesync/tubesync/local_settings.py | |
cp -v -a -t "${Python3_ROOT_DIR}"/lib/python3.*/site-packages/background_task/ patches/background_task/* | |
cp -v -a -t "${Python3_ROOT_DIR}"/lib/python3.*/site-packages/yt_dlp/ patches/yt_dlp/* | |
- name: Run Django tests | |
run: cd tubesync && python3 manage.py test --verbosity=2 | |
containerise: | |
if: ${{ !cancelled() && 'success' == needs.info.result }} | |
needs: ['info', 'test'] | |
runs-on: ubuntu-latest | |
timeout-minutes: 120 | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into GitHub Container Registry | |
env: | |
DOCKER_REGISTRY: https://ghcr.io | |
DOCKER_USERNAME: ${{ github.actor }} | |
DOCKER_TOKEN: ${{ 'meeb' == github.repository_owner && secrets.REGISTRY_ACCESS_TOKEN || secrets.GITHUB_TOKEN }} | |
run: echo "${DOCKER_TOKEN}" | docker login --password-stdin --username "${DOCKER_USERNAME}" "${DOCKER_REGISTRY}" | |
- name: Build image for `dive` | |
id: build-dive-image | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
IMAGE_NAME=${{ env.IMAGE_NAME }} | |
FFMPEG_DATE=${{ needs.info.outputs.ffmpeg-date }} | |
FFMPEG_VERSION=${{ needs.info.outputs.ffmpeg-version }} | |
YTDLP_DATE=${{ fromJSON(needs.info.outputs.ytdlp-latest-release).tag.name }} | |
cache-from: type=gha | |
load: true | |
platforms: linux/amd64 | |
push: false | |
tags: ghcr.io/${{ needs.info.outputs.lowercase-github-actor }}/${{ env.IMAGE_NAME }}:dive | |
- name: Analysis with `dive` | |
continue-on-error: false | |
run: | | |
docker run --rm \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
'ghcr.io/wagoodman/dive' \ | |
'ghcr.io/${{ needs.info.outputs.lowercase-github-actor }}/${{ env.IMAGE_NAME }}:dive' \ | |
--ci \ | |
--highestUserWastedPercent '0.05' \ | |
--highestWastedBytes '50M' | |
- name: Build and push | |
id: build-push | |
timeout-minutes: 60 | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ 'success' == needs.test.result && 'meeb' == github.repository_owner && 'pull_request' != github.event_name && 'true' || 'false' }} | |
tags: ghcr.io/${{ needs.info.outputs.lowercase-github-actor }}/${{ env.IMAGE_NAME }}:latest | |
cache-from: | | |
type=registry,ref=ghcr.io/${{ needs.info.outputs.lowercase-github-actor }}/${{ env.IMAGE_NAME }}:latest | |
type=registry,ref=ghcr.io/${{ needs.info.outputs.lowercase-github-repository_owner }}/${{ env.IMAGE_NAME }}:latest | |
type=gha | |
cache-to: | | |
type=gha,mode=max | |
${{ 'meeb' == github.repository_owner && 'pull_request' != github.event_name && 'type=inline' || '' }} | |
build-args: | | |
IMAGE_NAME=${{ env.IMAGE_NAME }} | |
FFMPEG_DATE=${{ needs.info.outputs.ffmpeg-date }} | |
FFMPEG_VERSION=${{ needs.info.outputs.ffmpeg-version }} | |
YTDLP_DATE=${{ fromJSON(needs.info.outputs.ytdlp-latest-release).tag.name }} |