Skip to content

Commit

Permalink
Add reusable actions to build and push images to Docker Hub
Browse files Browse the repository at this point in the history
As discussed in ckan/ckan#8143

TODO: Decide when to trigger the builds
  • Loading branch information
amercader committed Jul 2, 2024
1 parent 769e3e2 commit 2acd1c3
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 33 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/publish-docker-2.10-py3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Build and push CKAN 2.10 images (python)

on: push

jobs:
call-reusable-workflow:
uses: ./.github/workflows/reusable-docker-publish.yml
with:
ckan-major-version: "2.10"
ckan-version: "2.10.4"
base-tags: '["ckan/ckan-base:2.10-py3.10", "ckan/ckan-base:2.10.4-py3.10"]'
dev-tags: '["ckan/ckan-dev:2.10-py3.10", "ckan/ckan-dev:2.10.4-py3.10"]'
12 changes: 12 additions & 0 deletions .github/workflows/publish-docker-2.10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Build and push CKAN 2.10 images (alpine)

on: push

jobs:
call-reusable-workflow:
uses: ./.github/workflows/reusable-docker-publish.yml
with:
ckan-major-version: "2.10"
ckan-version: "2.10.4"
base-tags: '["ckan/ckan-base:2.10", "ckan/ckan-base:2.10.4"]'
dev-tags: '["ckan/ckan-dev:2.10", "ckan/ckan-dev:2.10.4"]'
13 changes: 13 additions & 0 deletions .github/workflows/publish-docker-2.11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Build and push CKAN 2.11 images

on: push

jobs:
call-reusable-workflow:
uses: ./.github/workflows/reusable-docker-publish.yml
with:
ckan-major-version: "2.11"
ckan-version: "2.11"
# TODO: minor version
base-tags: '["ckan/ckan-base:2.11", "ckan/ckan-base:2.11-py3.10"]'
dev-tags: '["ckan/ckan-dev:2.11", "ckan/ckan-dev:2.11-py3.10"]'
12 changes: 12 additions & 0 deletions .github/workflows/publish-docker-2.9-py3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Build and push CKAN 2.9 images (python)

on: push

jobs:
call-reusable-workflow:
uses: ./.github/workflows/reusable-docker-publish.yml
with:
ckan-major-version: "2.9"
ckan-version: "2.9.11"
base-tags: '["ckan/ckan-base:2.9-py3.9", "ckan/ckan-base:2.9.11-py3.9"]'
dev-tags: '["ckan/ckan-dev:2.9-py3.9", "ckan/ckan-dev:2.9.11-py3.9"]'
12 changes: 12 additions & 0 deletions .github/workflows/publish-docker-2.9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Build and push CKAN 2.9 images (alpine)

on: push

jobs:
call-reusable-workflow:
uses: ./.github/workflows/reusable-docker-publish.yml
with:
ckan-major-version: "2.9"
ckan-version: "2.9.11"
base-tags: '["ckan/ckan-base:2.9", "ckan/ckan-base:2.9.11"]'
dev-tags: '["ckan/ckan-dev:2.9", "ckan/ckan-dev:2.9.11"]'
40 changes: 7 additions & 33 deletions .github/workflows/publish-docker-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,10 @@ on:
schedule:
- cron: '15 5 * * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build ckan-base master
uses: docker/build-push-action@v6
with:
context: ckan-master/base
file: ckan-master/base/Dockerfile
push: true
build-args: |
CKAN_VERSION=master
tags: |
ckan/ckan-base:master
- name: Build ckan-dev master
uses: docker/build-push-action@v6
with:
context: ckan-master/dev
file: ckan-master/dev/Dockerfile
push: true
build-args: |
CKAN_VERSION=master
tags: |
ckan/ckan-dev:master
call-reusable-workflow:
uses: ./.github/workflows/reusable-docker-publish.yml
with:
ckan-major-version: "master"
ckan-version: "master"
base-tags: '["ckan/ckan-base:master", "ckan/ckan-base:master-py3.10"]'
dev-tags: '["ckan/ckan-dev:master", "ckan/ckan-dev:master-py3.10"]'
53 changes: 53 additions & 0 deletions .github/workflows/reusable-docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Reusable CKAN Docker images build and push

on:
workflow_call:
inputs:
ckan-major-version:
required: true
type: string
ckan-version:
required: true
type: string
base-tags:
required: true
type: string
dev-tags:
required: true
type: string
docker-file:
required: false
default: 'Dockerfile'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build ${{ inputs.ckan-major-version }} base
uses: docker/build-push-action@v6
with:
context: ckan-${{ inputs.ckan-major-version }}/base
file: ckan-${{ inputs.ckan-major-version }}/base/${{ inputs.docker-file }}
push: true
build-args: |
CKAN_VERSION=${{ inputs.ckan-version }}
tags: ${{ fromJson(inputs.base-tags) }}

- name: Build ${{ inputs.ckan-major-version }} dev
uses: docker/build-push-action@v6
with:
context: ckan-${{ inputs.ckan-major-version }}/dev
file: ckan-${{ inputs.ckan-major-version }}/dev/${{ inputs.docker-file }}
push: true
build-args: |
CKAN_VERSION=${{ inputs.ckan-version }}
tags: ${{ fromJson(inputs.dev-tags) }}

0 comments on commit 2acd1c3

Please sign in to comment.