Publish Scrypted Docker Image #864
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: Publish Scrypted Docker Image | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "The npm tag used to build the Docker image. The tag will be resolved as a specific version on npm, and that will be used to version the docker image." | |
required: true | |
publish_tag: | |
description: "The versioned tag for the published Docker image. NPM will use the minor version, Docker should only specify a patch version." | |
required: false | |
release: | |
types: [published] | |
jobs: | |
build: | |
name: Push Docker image to Docker Hub | |
runs-on: self-hosted | |
# runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
BASE: [ | |
["jammy-nvidia", ".s6"], | |
["jammy-full", ".s6"], | |
["jammy-lite", ""], | |
] | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: NPM Package Request | |
id: npm-request | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: 'https://registry.npmjs.org/@scrypted/server' | |
method: 'GET' | |
- name: Set NPM Version | |
id: package-version | |
run: echo "NPM_VERSION=${{ fromJson(steps.npm-request.outputs.response)['dist-tags'][ github.event.inputs.tag] }}" >> "$GITHUB_OUTPUT" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up SSH | |
uses: MrSquaare/ssh-setup-action@v2 | |
with: | |
host: ${{ secrets.DOCKER_SSH_HOST_AMD64 }} | |
private-key: ${{ secrets.DOCKER_SSH_PRIVATE_KEY }} | |
- name: Set up SSH | |
uses: MrSquaare/ssh-setup-action@v2 | |
with: | |
host: ${{ secrets.DOCKER_SSH_HOST_ARM64 }} | |
private-key: ${{ secrets.DOCKER_SSH_PRIVATE_KEY }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
platforms: linux/amd64 | |
append: | | |
- endpoint: ssh://${{ secrets.DOCKER_SSH_USER }}@${{ secrets.DOCKER_SSH_HOST_AMD64 }} | |
platforms: linux/amd64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
platforms: linux/arm64 | |
append: | | |
- endpoint: ssh://${{ secrets.DOCKER_SSH_USER }}@${{ secrets.DOCKER_SSH_HOST_ARM64 }} | |
platforms: linux/arm64 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to Github Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
build-args: | | |
BASE=${{ matrix.BASE[0] }} | |
SCRYPTED_INSTALL_VERSION=${{ steps.package-version.outputs.NPM_VERSION }} | |
context: install/docker/ | |
file: install/docker/Dockerfile${{ matrix.BASE[1] }} | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ format('koush/scrypted:v{1}-{0}', matrix.BASE[0], github.event.inputs.publish_tag || steps.package-version.outputs.NPM_VERSION) }} | |
${{ matrix.BASE[0] == 'jammy-full' && format('koush/scrypted:{0}', github.event.inputs.tag) || '' }} | |
${{ github.event.inputs.tag == 'latest' && matrix.BASE[0] == 'jammy-nvidia' && 'koush/scrypted:nvidia' || '' }} | |
${{ github.event.inputs.tag == 'latest' && matrix.BASE[0] == 'jammy-full' && 'koush/scrypted:full' || '' }} | |
${{ github.event.inputs.tag == 'latest' && matrix.BASE[0] == 'jammy-lite' && 'koush/scrypted:lite' || '' }} | |
${{ format('ghcr.io/koush/scrypted:v{1}-{0}', matrix.BASE[0], github.event.inputs.publish_tag || steps.package-version.outputs.NPM_VERSION) }} | |
${{ matrix.BASE[0] == 'jammy-full' && format('ghcr.io/koush/scrypted:{0}', github.event.inputs.tag) || '' }} | |
${{ github.event.inputs.tag == 'latest' && matrix.BASE[0] == 'jammy-nvidia' && 'ghcr.io/koush/scrypted:nvidia' || '' }} | |
${{ github.event.inputs.tag == 'latest' && matrix.BASE[0] == 'jammy-full' && 'ghcr.io/koush/scrypted:full' || '' }} | |
${{ github.event.inputs.tag == 'latest' && matrix.BASE[0] == 'jammy-lite' && 'ghcr.io/koush/scrypted:lite' || '' }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |