mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-07-17 16:47:05 +00:00
* ci: publish Docker images to GHCR alongside Docker Hub Adds ghcr.io/ether/etherpad as a second publish target on release tags, reusing the existing docker/metadata-action step so the same SemVer tags (e.g. 2.6.1, 2.6, 2, latest) are pushed to both registries. Motivation: downstream consumers (Helm charts in particular) hit Docker Hub anonymous pull rate limits. GHCR has no such limits and the workflow already runs with GITHUB_TOKEN, so this is additive with no new secrets required. Docker Hub remains the primary/canonical source; GHCR is a mirror. Note: this only affects future release tags. The 2.6.1 tag already on Docker Hub will need to be mirrored separately (e.g. via skopeo) if downstream needs it on GHCR before the next release. * address qodo review: scope packages:write to publish job, document GHCR Two fixes from the qodo code review on #7569: 1. Overprivileged PR token (security). The original change set 'packages: write' at workflow level, which meant pull_request runs (whose Test step executes PR-controlled code) also inherited push access to GHCR. Splits the workflow into two jobs: - build-test: runs on pull_request and push with contents:read only. Does the single-arch load+test as before. - publish: needs build-test, runs only on push with packages:write. Does the multi-arch build-and-push, Docker Hub description update, and ether-charts bump. Docker Hub login is also now gated by job-level 'if' (same effect as the previous step-level 'if'). 2. Docs miss GHCR option. Updates doc/docker.md and README.md to document the GHCR mirror alongside Docker Hub with equivalent pull examples, so downstream users discovering via docs can choose the mirror to avoid Docker Hub rate limits.
166 lines
4.8 KiB
YAML
166 lines
4.8 KiB
YAML
name: "Docker"
|
|
on:
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'doc/**'
|
|
push:
|
|
branches:
|
|
- 'develop'
|
|
paths-ignore:
|
|
- 'doc/**'
|
|
tags:
|
|
- 'v?[0-9]+.[0-9]+.[0-9]+'
|
|
env:
|
|
TEST_TAG: etherpad/etherpad:test
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build-test:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
env:
|
|
PNPM_HOME: ~/.pnpm-store
|
|
steps:
|
|
-
|
|
name: Check out
|
|
uses: actions/checkout@v6
|
|
with:
|
|
path: etherpad
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
-
|
|
name: Build and export to Docker
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: ./etherpad
|
|
target: production
|
|
load: true
|
|
tags: ${{ env.TEST_TAG }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
- uses: actions/cache@v5
|
|
name: Setup gnpm cache
|
|
if: always()
|
|
with:
|
|
path: |
|
|
${{ env.PNPM_HOME }}
|
|
~/.local/share/gnpm
|
|
/usr/local/bin/gnpm
|
|
/usr/local/bin/gnpm-0.0.12
|
|
key: ${{ runner.os }}-gnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gnpm-store-
|
|
- name: Setup gnpm
|
|
uses: SamTV12345/gnpm-setup@main
|
|
with:
|
|
version: 0.0.12
|
|
-
|
|
name: Test
|
|
working-directory: etherpad
|
|
run: |
|
|
docker run --rm -d -p 9001:9001 --name test ${{ env.TEST_TAG }}
|
|
./bin/installDeps.sh
|
|
docker logs -f test &
|
|
while true; do
|
|
echo "Waiting for Docker container to start..."
|
|
status=$(docker container inspect -f '{{.State.Health.Status}}' test) || exit 1
|
|
case ${status} in
|
|
healthy) break;;
|
|
starting) sleep 2;;
|
|
*) printf %s\\n "unexpected status: ${status}" >&2; exit 1;;
|
|
esac
|
|
done
|
|
(cd src && gnpm run test-container)
|
|
git clean -dxf .
|
|
|
|
publish:
|
|
needs: build-test
|
|
if: github.event_name == 'push'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
-
|
|
name: Check out
|
|
uses: actions/checkout@v6
|
|
with:
|
|
path: etherpad
|
|
-
|
|
name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v4
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
-
|
|
name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v6
|
|
with:
|
|
images: |
|
|
etherpad/etherpad
|
|
ghcr.io/ether/etherpad
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
-
|
|
name: Log in to Docker Hub
|
|
uses: docker/login-action@v4
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
-
|
|
name: Log in to GHCR
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
-
|
|
name: Build and push
|
|
id: build-docker
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: ./etherpad
|
|
target: production
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
- name: Update repo description
|
|
uses: peter-evans/dockerhub-description@v5
|
|
if: github.ref == 'refs/heads/master'
|
|
with:
|
|
readme-filepath: ./etherpad/README.md
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
repository: etherpad/etherpad
|
|
enable-url-completion: true
|
|
- name: Check out ether-charts
|
|
if: github.ref == 'refs/heads/develop'
|
|
uses: actions/checkout@v6
|
|
with:
|
|
path: ether-charts
|
|
repository: ether/ether-charts
|
|
token: ${{ secrets.ETHER_CHART_TOKEN }}
|
|
- name: Update tag in values-dev.yaml
|
|
if: success() && github.ref == 'refs/heads/develop'
|
|
working-directory: ether-charts
|
|
run: |
|
|
sed -i 's/tag: ".*"/tag: "${{ steps.build-docker.outputs.digest }}"/' values-dev.yaml
|
|
- name: Commit and push changes
|
|
working-directory: ether-charts
|
|
if: success() && github.ref == 'refs/heads/develop'
|
|
run: |
|
|
git config --global user.name 'github-actions[bot]'
|
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
|
git add values-dev.yaml
|
|
git commit -m 'Update develop image tag'
|
|
git push
|