Skip to content

Publish Docker Image #10

Publish Docker Image

Publish Docker Image #10

Workflow file for this run

name: Publish Docker Image
on:
workflow_dispatch:
inputs:
nextcloud_version:
description: "Nextcloud version (e.g. 30.0.4)"
required: true
type: string
enterprise_url:
description: "Enterprise archive URL (leave empty for community edition)"
required: false
default: ""
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/nextcloud
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Determine edition
id: edition
run: |
if [ -n "${{ inputs.enterprise_url }}" ]; then
echo "name=enterprise" >> "$GITHUB_OUTPUT"
else
echo "name=community" >> "$GITHUB_OUTPUT"
fi
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Lower case docker image name
id: docker_image
uses: ASzc/change-string-case-action@v6
with:
string: ${{ github.repository }}
- name: Generate image tags
id: tags
run: |
VERSION="${{ inputs.nextcloud_version }}"
EDITION="${{ steps.edition.outputs.name }}"
IMAGE="${{ env.REGISTRY }}/${{ steps.docker_image.outputs.lowercase }}"
if [ "$EDITION" = "enterprise" ]; then
TAGS="${IMAGE}:${VERSION}-enterprise"
else
TAGS="${IMAGE}:${VERSION}"
fi
echo "tags=$TAGS" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./nextcloud
push: true
tags: ${{ steps.tags.outputs.tags }}
build-args: |
NEXTCLOUD_VERSION=${{ inputs.nextcloud_version }}
ENTERPRISE_ARCHIVE_URL=${{ inputs.enterprise_url }}
cache-from: type=gha
cache-to: type=gha,mode=max