Skip to content

Commit

Permalink
update CI and versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricebrito committed Oct 3, 2024
1 parent 5d24828 commit 993dcda
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 16 deletions.
73 changes: 57 additions & 16 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,64 @@
name: Build and publish Docker image
name: Build and Publish Docker

on:
push:
branches: [ main, master, develop ]
tags:
- "*"
pull_request:
branches: [ main, master, develop ]
workflow_dispatch:
inputs:
push:
description: 'Push to dockerhub'
type: boolean
default: false

jobs:
push_to_registry:
name: Build and push Docker image to Docker Hub
build-and-publish-docker:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Push to Docker Hub
uses: docker/build-push-action@v1
- name: Checkout code
uses: actions/checkout@v3

- name: Read docker name
id: yaml-docker-name
uses: jbutcher5/read-yaml@main
with:
file: 'build.yml'
key-path: '["docker_image_name"]'

- name: Read docker version
id: yaml-docker-version
uses: jbutcher5/read-yaml@main
with:
file: 'build.yml'
key-path: '["docker_image_version"]'

- name: Generate docker tag
env:
GITHUB_BRANCH: ${{ github.ref }}
docker_image_name: ${{ steps.yaml-docker-name.outputs.data }}
docker_image_version: ${{ steps.yaml-docker-version.outputs.data }}
run: |
branch_name=${GITHUB_BRANCH#refs/heads/}
echo "branch_name=${GITHUB_BRANCH#refs/heads/}" >> $GITHUB_ENV
if [[ "$branch_name" = "main" ]]
then
mType=""
else
mType="dev"
fi
echo "docker_tag=$docker_image_name:$mType$docker_image_version" >> $GITHUB_ENV
echo "docker_tag_latest=$docker_image_name:${mType}latest" >> $GITHUB_ENV
- name: Login to Docker Hub
if: ${{ github.event.inputs.push == 'true' }}
uses: docker/login-action@v2
with:
path: ./
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: eoepca/iat-jupyterlab
tag_with_ref: true

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event.inputs.push == 'true' }}
no-cache: true
tags: |
${{ env.docker_tag }}
${{ env.docker_tag_latest }}
2 changes: 2 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker_image_name: eoepca/iat-jupyterlab
docker_image_version: 1.2.0

0 comments on commit 993dcda

Please sign in to comment.