Skip to content

Commit

Permalink
Streamline docker image builds, add alma9 images. (#169)
Browse files Browse the repository at this point in the history
* Add a9 py38-11 images.

* Update tags, test composite action.

* Update action template.

* Typo.

* Move checkout action.

* Pass secrets as inputs.

* Use composite actions for a9.

* Use input choice.

* Test input type.

* Fix boolean usage.

* Use action template.
  • Loading branch information
riga authored Nov 5, 2023
1 parent 465b723 commit e4afe3a
Show file tree
Hide file tree
Showing 16 changed files with 616 additions and 269 deletions.
48 changes: 48 additions & 0 deletions .github/actions/build-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
inputs:
dockerhub_username:
description: "The DockerHub username."
required: true

dockerhub_token:
description: "The DockerHub login token."
required: true

docker_file:
description: "The docker file."
required: true

tags:
description: "Image tags (csv)."
required: true

platforms:
description: "Platforms to build for (csv)."
default: "linux/amd64,linux/arm64"

push_image:
description: "Whether to push to DockerHub."
default: false

runs:
using: "composite"
steps:
- name: Set up QEMU 🌈
uses: docker/setup-qemu-action@v3

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

- name: Login to Docker Hub 🎪
uses: docker/login-action@v3
with:
username: ${{ inputs.dockerhub_username }}
password: ${{ inputs.dockerhub_token }}

- name: Build and deploy image 🐳
uses: docker/build-push-action@v5
with:
context: docker
file: ${{ inputs.docker_file }}
platforms: ${{ inputs.platforms }}
push: ${{ inputs.push_image }}
tags: ${{ inputs.tags }}
132 changes: 110 additions & 22 deletions .github/workflows/deploy_images_a9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,130 @@ name: Deploy images AlmaLinux9
on:
workflow_dispatch:
inputs:
build_only:
description: Build only? (true|false)
required: false
default: 'false'
push_image:
description: "Push image to DockerHub"
type: boolean
default: false

specific_job:
description: Run a specific job? (a9-py37)
required: false
default: ''
description: "Specific job to run"
type: choice
default: "none"
options:
- "none"
- py37
- py38
- py39
- py310
- py311
- example

jobs:
a9-py37:
if: ${{ github.event.inputs.specific_job == '' || contains(github.event.inputs.specific_job, 'a9-py37') }}
if: ${{ github.event.inputs.specific_job == 'none' || contains(github.event.inputs.specific_job, 'py37') }}
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Build and deploy image 🐳
uses: ./.github/actions/build-image
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
docker_file: docker/Dockerfile_alma9_py37
tags: riga/law:a9-py37,riga/law:py37
push_image: ${{ github.event.inputs.push_image == 'true' }}

a9-py38:
if: ${{ github.event.inputs.specific_job == 'none' || contains(github.event.inputs.specific_job, 'py38') }}
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up QEMU 🌈
uses: docker/setup-qemu-action@v3
- name: Build and deploy image 🐳
uses: ./.github/actions/build-image
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
docker_file: docker/Dockerfile_alma9_py38
tags: riga/law:a9-py38,riga/law:py38
push_image: ${{ github.event.inputs.push_image == 'true' }}

- name: Set up Docker Buildx ✨
uses: docker/setup-buildx-action@v3
a9-py39:
if: ${{ github.event.inputs.specific_job == 'none' || contains(github.event.inputs.specific_job, 'py39') }}
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Login to Docker Hub 🎪
uses: docker/login-action@v3
- name: Build and deploy image 🐳
uses: ./.github/actions/build-image
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
docker_file: docker/Dockerfile_alma9_py39
tags: riga/law:a9-py39,riga/law:py39
push_image: ${{ github.event.inputs.push_image == 'true' }}

a9-py310:
if: ${{ github.event.inputs.specific_job == 'none' || contains(github.event.inputs.specific_job, 'py310') }}
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Build and deploy image 🐳
uses: ./.github/actions/build-image
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
docker_file: docker/Dockerfile_alma9_py310
tags: riga/law:a9-py310,riga/law:py310
push_image: ${{ github.event.inputs.push_image == 'true' }}

a9-py311:
if: ${{ github.event.inputs.specific_job == 'none' || contains(github.event.inputs.specific_job, 'py311') }}
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Build and deploy image 🐳
uses: ./.github/actions/build-image
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
docker_file: docker/Dockerfile_alma9_py311
tags: riga/law:a9-py311,riga/law:a9-py3,riga/law:a9,riga/law:py311,riga/law:py3,riga/law:latest
push_image: ${{ github.event.inputs.push_image == 'true' }}

example:
if: ${{ github.event.inputs.push_image == 'true' && (github.event.inputs.specific_job == 'none' || contains(github.event.inputs.specific_job, 'example')) }}
needs: a9-py311
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Build and deploy image 🐳
uses: docker/build-push-action@v5
uses: ./.github/actions/build-image
with:
context: docker
file: docker/Dockerfile_alma9_py37
platforms: linux/amd64,linux/arm64
push: ${{ github.event.inputs.build_only != 'true' }}
tags: riga/law:a9-py37
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
docker_file: docker/Dockerfile_example
tags: riga/law:example
push_image: true
Loading

0 comments on commit e4afe3a

Please sign in to comment.