Skip to content

Publish a Docker image to GHCR on every release #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/publish-ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish Docker image to GHCR

on:
release:
types: [published]

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/platformsh/upsun-cli:${{ github.event.release.tag_name }}
ghcr.io/platformsh/upsun-cli:latest
Copy link
Contributor

@pjcdawkins pjcdawkins Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems we should/could make it ghcr.io/upsun/cli

and we should/could also publish ghcr.io/platformsh/cli ? - if so it'd need multiple or generated Dockerfiles

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can easily parametrize the Dockerfile with a dynamic VENDOR argument for that, no need for multiple or generated Dockerfiles.

The idea was that we don't need a Platform.sh CLI image for now, that's why I didn't mess with it - otherwise I'm happy to adjust.

13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:24.04
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM ubuntu:24.04
FROM debian:stable-slim

?


# Install dependencies
RUN apt-get update && \
apt-get install -y curl bash git ssh-client && \
rm -rf /var/lib/apt/lists/*

# Install Upsun CLI
ARG VERSION=
RUN curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | VENDOR=upsun INSTALL_METHOD=raw VERSION=$VERSION bash

# Default command
ENTRYPOINT ["upsun"]