Skip to content

first try at adding a preview build #21

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
21 changes: 19 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ jobs:
run: |
VERSIONS=$(parse-dockerfile Dockerfile | jq -cr '[.instructions[] | select(.kind=="LABEL" or .kind=="ARG") | select(.arguments.value | contains("org.opencontainers.image") or startswith("APOLLO_")).arguments.value | match("([^=]*)=(.*)") | .captures | {(.[0].string) : .[1].string}] | add')
echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT"
- name: Check Image to Build Post-Merge Does Not Already Exist

# Check if preview version is defined as workflow input
if [ -n "${{ inputs.preview_router_version }}" ]; then
echo "has_preview=true" >> "$GITHUB_OUTPUT"
echo "preview_version=${{ inputs.preview_router_version }}" >> "$GITHUB_OUTPUT"
else
echo "has_preview=false" >> "$GITHUB_OUTPUT"
fi
Comment on lines +36 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think, if we can use the docker/metadata-action we probably don't need to do this. You can use the tags field there to set all sorts of conditonal behaviour: https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input

- name: Check Image Does Not Already Exist
id: check-image
run: |
TAG=${{ fromJSON(steps.get-versions.outputs.versions)['org.opencontainers.image.version'] }}_router${{ fromJSON(steps.get-versions.outputs.versions).APOLLO_ROUTER_VERSION }}_mcp-server${{ fromJSON(steps.get-versions.outputs.versions).APOLLO_MCP_SERVER_VERSION }}
Expand Down Expand Up @@ -141,9 +149,18 @@ jobs:
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Build and Push Preview Docker Image
if: steps.get-versions.outputs.has_preview == 'true'
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
with:
push: true
platforms: ${{ env.PLATFORMS }}
build-args: |
APOLLO_ROUTER_VERSION=${{ steps.get-versions.outputs.preview_version }}
tags: |
${{ env.NAMESPACED_REGISTRY }}:${{ github.event_name == 'pull_request' && format('PR{0}-router-preview', github.event.number) || 'router-preview' }}
Comment on lines +152 to +161
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the same way here, if we use the metadata action, I think that's the only thing that needs to change, so this should simplify things here

annotations: ${{ steps.meta.outputs.annotations }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ env.PLATFORMS }}
- name: Create GitHub Release
if: ${{ github.event_name != 'pull_request' }}
uses: comnoco/create-release-action@6ac85b5a67d93e181c1a8f97072e2e3ffc582ec4
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ FROM almalinux:10-minimal@sha256:9cdcbb8b9b0e522e4c190d4f1db67ebd443736630ad77cf
ARG S6_OVERLAY_VERSION=3.2.1.0
# renovate: datasource=github-releases depName=apollographql/router
ARG APOLLO_ROUTER_VERSION=2.3.0
# Preview router version - set this to build preview images automatically
# once new preview is out, we'll uncomment this.
#ARG APOLLO_ROUTER_PREVIEW_VERSION=2.3.0-preview.0
Comment on lines +8 to +10
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm tempted to ignore this for now, and just focus on getting on-demand builds of router previews. However, I'm writing a doc at the moment about publishing multiple router versions etc, and I'll include a section on preview versions. We can probably rig up renovate so that it will bump this for us, as and when preview versions exist but if we can get the on-demand part working for now that would be a great start.

# renovate: datasource=github-releases depName=apollographql/apollo-mcp-server
ARG APOLLO_MCP_SERVER_VERSION=0.4.2

Expand Down
Loading