Skip to content

Commit

Permalink
Auto determine architecture & Update workflow for Plexdrive 5.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rapejim committed Jun 10, 2024
2 parents 3135d27 + ddbdec1 commit 0b4e195
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 12 deletions.
57 changes: 48 additions & 9 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ name: Publish on Docker & ghcr.io
# documentation.

on:
# schedule:
# - cron: '15 6 * * *'
# On push commit trigger
push:
# branches:
# - develop
Expand All @@ -16,8 +15,15 @@ on:
# branches:
# - develop
# - beta

# Allows manual trigger
workflow_dispatch:

# Allows external webhook trigger
repository_dispatch:
types:
- "Plex Update Webhook"

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
Expand All @@ -35,21 +41,27 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
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

# Login Docker Hub registry except on PR
# https://github.com/docker/login-action
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Login Github registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand All @@ -59,21 +71,48 @@ jobs:
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
uses: docker/metadata-action@v5
with:
tags: |
latest
type=ref,event=branch
type=raw,latest
images: |
${{ github.repository }}
${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Extract metadata (tags, labels) for Docker (Plexdrive 5.2.1)
# https://github.com/docker/metadata-action
- name: Extract Docker metadata (Plexdrive 5.2.1)
id: meta_pd521
uses: docker/metadata-action@v5
with:
tags: |
pd521
type=ref,event=branch,suffix=-pd521
images: |
${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image (Plexdrive 5.2.1) with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image (Plexdrive 5.2.1)
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
build-args: |
PLEXDRIVE_VERSION=5.2.1
tags: ${{ steps.meta_pd521.outputs.tags }}
labels: ${{ steps.meta_pd521.outputs.labels }}
18 changes: 15 additions & 3 deletions root/plexdrive-install.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
#!/bin/sh
# Plexdrive updater
# Plexdrive installer

# Determine architecture
ARCH=$(dpkg --print-architecture)
# Validate architecture
if [ "$ARCH" != "amd64" ] && [ "$ARCH" != "arm64" ]; then
echo "Arquitectura no soportada: $ARCH. El script solo soporta amd64 y arm64."
exit 1
fi

# Get plexdrive
cd /tmp
wget "https://github.com/plexdrive/plexdrive/releases/download/$PLEXDRIVE_VERSION/plexdrive-linux-$ARCH" -q -O plexdrive
echo "Downloading https://github.com/plexdrive/plexdrive/releases/download/$PLEXDRIVE_VERSION/plexdrive-linux-$ARCH"
wget "https://github.com/plexdrive/plexdrive/releases/download/$PLEXDRIVE_VERSION/plexdrive-linux-$ARCH" --no-verbose -O plexdrive
chmod -c +x /tmp/plexdrive
version=$(/tmp/plexdrive --version)

# Install plexdrive
echo "Installing Plexdrive v. ${version}"
#install plexdrive
mv -v /tmp/plexdrive /usr/local/bin/
chown -c root:root /usr/local/bin/plexdrive

0 comments on commit 0b4e195

Please sign in to comment.