Skip to content

Commit

Permalink
Add GitHub workflows for Docker builds, artifact removal, and workflo…
Browse files Browse the repository at this point in the history
…w pruning
  • Loading branch information
Kamdzy committed Feb 24, 2025
1 parent 5b47125 commit 1e640c4
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/external_trigger_edited.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: External Trigger Docker

on:
workflow_dispatch:
inputs:
framework:
description: ".net framework"
type: string
required: true
default: net6.0
version:
description: "Sonarr version"
type: string
required: true
default: 4.0.0.0

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.github_token }}

- name: Date
id: date
run: echo "::set-output name=BUILD_DATE::$(date '+%Y-%m-%dT%H:%M:%S%:z')"

- name: Publish to ghcr.io
uses: docker/build-push-action@v6
with:
push: true
context: .
file: ./Dockerfileedited
platforms: linux/amd64
tags: |
ghcr.io/kamdzy/sonarr:latest
ghcr.io/kamdzy/sonarr:v${{ inputs.version }}
build-args: |
VERSION=2.1
SONARR_VERSION=${{ inputs.version }}
BUILD_DATE=${{ steps.date.outputs.BUILD_DATE }}
cache-from: type=gha
cache-to: type=gha,mode=max

# - name: Publish to ghcr.io
# uses: docker/build-push-action@v6
# with:
# push: true
# context: .
# file: ./Dockerfile.aarch64edited
# platforms: linux/arm64
# tags: |
# ghcr.io/kamdzy/sonarr:latest
# ghcr.io/kamdzy/sonarr:v${{ inputs.version }}
# build-args: |
# VERSION=2.1
# SONARR_VERSION=${{ inputs.version }}
# BUILD_DATE=${{ steps.date.outputs.BUILD_DATE }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
62 changes: 62 additions & 0 deletions .github/workflows/prune_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Prune workflow runs
on:
schedule:
# Run monthly, at 00:00 on the 1st day of month.
- cron: "0 0 1 * *"
workflow_dispatch:
inputs:
days:
description: "Number of days."
required: true
default: 30
minimum_runs:
description: "The minimum runs to keep for each workflow."
required: true
default: 6
delete_workflow_pattern:
description: "The name or filename of the workflow. if not set then it will target all workflows."
required: false
delete_workflow_by_state_pattern:
description: "Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually"
required: true
default: "All"
type: choice
options:
- "All"
- active
- deleted
- disabled_inactivity
- disabled_manually
delete_run_by_conclusion_pattern:
description: "Remove workflow by conclusion: action_required, cancelled, failure, skipped, success"
required: true
default: "All"
type: choice
options:
- "All"
- action_required
- cancelled
- failure
- skipped
- success
dry_run:
description: "Only log actions, do not perform any delete operations."
required: false

jobs:
del_runs:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: ${{ github.event.inputs.days }}
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }}
delete_run_by_conclusion_pattern: ${{ github.event.inputs.delete_run_by_conclusion_pattern }}
dry_run: ${{ github.event.inputs.dry_run }}
17 changes: 17 additions & 0 deletions .github/workflows/remove_old_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Remove old artifacts

on:
schedule:
- cron: "0 1 * * *"

jobs:
remove-old-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
age: "1 hour"
skip-recent: 1
24 changes: 24 additions & 0 deletions .github/workflows/sync_fork.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Sync Fork

on:
schedule:
- cron: "5 */6 * * *" # At minute 5 past every 6th hour..
workflow_dispatch: # on button click

jobs:
sync:
runs-on: ubuntu-latest

steps:
- uses: tgymnich/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
personal_token: ${{ secrets.REPOSITORY_ACCESS_TOKEN }}
owner: linuxserver
base: master
head: master
merge_method: merge
pr_message: "Sync changes from upstream to downstream"
pr_title: Fork Sync
auto_approve: true
auto_merge: true
46 changes: 46 additions & 0 deletions Dockerfile.aarch64edited
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# syntax=docker/dockerfile:1

FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.21

# set version label
ARG BUILD_DATE
ARG VERSION
ARG SONARR_VERSION
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="kamdzy"

# set environment variables
ENV XDG_CONFIG_HOME="/config/xdg" \
SONARR_CHANNEL="v4-stable" \
SONARR_BRANCH="main" \
COMPlus_EnableDiagnostics=0 \
TMPDIR=/run/sonarr-temp

RUN \
echo "**** install packages ****" && \
apk add --no-cache \
icu-libs \
sqlite-libs \
xmlstarlet && \
echo "**** install sonarr ****" && \
mkdir -p /app/sonarr/bin && \
curl -o \
/tmp/sonarr.tar.gz -L \
"https://github.com/kamdzy/Sonarr/releases/download/v${SONARR_VERSION}/Sonarr.${SONARR_BRANCH}.${SONARR_VERSION}.linux-musl-arm64.tar.gz" && \
tar xzf \
/tmp/sonarr.tar.gz -C \
/app/sonarr/bin --strip-components=1 && \
echo -e "UpdateMethod=docker\nBranch=${SONARR_BRANCH}\nPackageVersion=${VERSION:-LocalBuild}\nPackageAuthor=[linuxserver.io](https://linuxserver.io)" > /app/sonarr/package_info && \
printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \
echo "**** cleanup ****" && \
rm -rf \
/app/sonarr/bin/Sonarr.Update \
/tmp/*

# add local files
COPY root/ /

# ports and volumes
EXPOSE 8989

VOLUME /config
46 changes: 46 additions & 0 deletions Dockerfileedited
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# syntax=docker/dockerfile:1

FROM ghcr.io/linuxserver/baseimage-alpine:3.21

# set version label
ARG BUILD_DATE
ARG VERSION
ARG SONARR_VERSION
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="kamdzy"

# set environment variables
ENV XDG_CONFIG_HOME="/config/xdg" \
SONARR_CHANNEL="v4-stable" \
SONARR_BRANCH="main" \
COMPlus_EnableDiagnostics=0 \
TMPDIR=/run/sonarr-temp

RUN \
echo "**** install packages ****" && \
apk add --no-cache \
icu-libs \
sqlite-libs \
xmlstarlet && \
echo "**** install sonarr ****" && \
mkdir -p /app/sonarr/bin && \
curl -o \
/tmp/sonarr.tar.gz -L \
"https://github.com/kamdzy/Sonarr/releases/download/v${SONARR_VERSION}/Sonarr.${SONARR_BRANCH}.${SONARR_VERSION}.linux-musl-x64.tar.gz" && \
tar xzf \
/tmp/sonarr.tar.gz -C \
/app/sonarr/bin --strip-components=1 && \
echo -e "UpdateMethod=docker\nBranch=${SONARR_BRANCH}\nPackageVersion=${VERSION:-LocalBuild}\nPackageAuthor=[linuxserver.io](https://linuxserver.io)" > /app/sonarr/package_info && \
printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \
echo "**** cleanup ****" && \
rm -rf \
/app/sonarr/bin/Sonarr.Update \
/tmp/*

# add local files
COPY root/ /

# ports and volumes
EXPOSE 8989

VOLUME /config

0 comments on commit 1e640c4

Please sign in to comment.