Skip to content

Commit

Permalink
Merge pull request #1 from tensorchord/ci
Browse files Browse the repository at this point in the history
initial commit
  • Loading branch information
xieydd authored Nov 22, 2024
2 parents b60fa2c + a70819d commit 1a0e248
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 0 deletions.
131 changes: 131 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Build and Push Docker Images

on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [released]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
packages: write

jobs:
configure:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-versions.outputs.result }}
steps:
- name: Checkout to repository
uses: actions/checkout@v4
- name: Get dependency versions
uses: mikefarah/[email protected]
id: get-versions
with:
cmd: yq eval -o=json -I=0 versions.yaml

build_and_push:
runs-on: ubuntu-latest
needs: configure
strategy:
# Prevent a failure in one image from stopping the other builds
fail-fast: false
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Login to GitHub Container Registry
uses: docker/[email protected]
if: ${{ !github.event.pull_request.head.repo.fork }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ !github.event.pull_request.head.repo.fork }}
with:
username: ${{ secrets.DOCKERIO_USERNAME }}
password: ${{ secrets.DOCKERIO_TOKEN }}

- name: Determine version change
id: changed-version
uses: tj-actions/changed-files@v45
with:
files: versions.yaml

- name: Determine image push
uses: actions/github-script@v7
id: should-release
with:
script: |
if (context.eventName == "pull_request") return false;
if (context.eventName == "workflow_dispatch") return true;
return "${{ steps.changed-version.outputs.any_changed }}" == "true";
- name: Set major postgres version
id: version
run: |
pg_major=$(echo ${{ matrix.cnpg }} | cut -d'.' -f1)
echo "pg_major=$pg_major" >> "$GITHUB_OUTPUT"
- name: Generate docker image tags
id: metadata
uses: docker/metadata-action@v5
with:
flavor: |
# Disable latest tag
latest=false
images: |
name=ghcr.io/${{ github.repository }}
name=tensorchord/cloudnative-vectorchord
tags: |
type=raw,value=${{ matrix.cnpg }}-${{ matrix.vectorchord }},enable=${{ steps.should-release.outputs.result }}
type=raw,value=${{ steps.version.outputs.pg_major }}-${{ matrix.vectorchord }},enable=${{ steps.should-release.outputs.result }}
type=raw,value=${{ matrix.cnpg }},enable=${{ steps.should-release.outputs.result }}
type=raw,value=${{ steps.version.outputs.pg_major }},enable=${{ steps.should-release.outputs.result }}
- name: Build and push image
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ !github.event.pull_request.head.repo.fork && steps.metadata.outputs.tags != '' }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
CNPG_TAG=${{ matrix.cnpg }}
VECTORCHORD_TAG=${{ matrix.vectorchord }}
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Build results
needs: [build_and_push]
steps:
- run: |
result="${{ needs.build_and_push.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG CNPG_TAG

FROM ghcr.io/cloudnative-pg/postgresql:$CNPG_TAG

Check warning on line 3 in Dockerfile

View workflow job for this annotation

GitHub Actions / build_and_push (14.14, 0.1.0)

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ghcr.io/cloudnative-pg/postgresql:$CNPG_TAG results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/

Check warning on line 3 in Dockerfile

View workflow job for this annotation

GitHub Actions / build_and_push (15.9, 0.1.0)

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ghcr.io/cloudnative-pg/postgresql:$CNPG_TAG results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/

Check warning on line 3 in Dockerfile

View workflow job for this annotation

GitHub Actions / build_and_push (16.5, 0.1.0)

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ghcr.io/cloudnative-pg/postgresql:$CNPG_TAG results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/

Check warning on line 3 in Dockerfile

View workflow job for this annotation

GitHub Actions / build_and_push (17.1, 0.1.0)

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ghcr.io/cloudnative-pg/postgresql:$CNPG_TAG results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/

ARG CNPG_TAG
ARG VECTORCHORD_TAG
ARG TARGETARCH

# drop to root to install packages
USER root
ADD https://github.com/tensorchord/VectorChord/releases/download/$VECTORCHORD_TAG/vchord-pg${CNPG_TAG%.*}_${VECTORCHORD_TAG#"v"}_$TARGETARCH.deb ./vchord.deb
RUN apt install ./vchord.deb

USER postgres

28 changes: 28 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"automerge": true,
"rebaseWhen": "conflicted",
"customManagers": [
{
"customType": "regex",
"fileMatch": ["^versions.yaml$"],
"matchStrings": [
"datasource=(?<datasource>\\S+) depName=(?<depName>\\S+)\\n.*?\"(?<currentValue>.*)\"\\n"
]
}
],
"packageRules": [
{
"matchUpdateTypes": ["major"],
"matchPackageNames": ["ghcr.io/cloudnative-pg/postgresql"],
"enabled": false
},
{
"matchPackageNames": ["ghcr.io/cloudnative-pg/postgresql"],
"groupName": "postgresql"
}
]
}
12 changes: 12 additions & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cnpg:
# renovate: datasource=docker depName=ghcr.io/cloudnative-pg/postgresql
- "14.14"
# renovate: datasource=docker depName=ghcr.io/cloudnative-pg/postgresql
- "15.9"
# renovate: datasource=docker depName=ghcr.io/cloudnative-pg/postgresql
- "16.5"
# renovate: datasource=docker depName=ghcr.io/cloudnative-pg/postgresql
- "17.1"
vectorchord:
# renovate: datasource=github-releases depName=tensorchord/VectorChord
- "0.1.0"

0 comments on commit 1a0e248

Please sign in to comment.