-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d24828
commit 993dcda
Showing
2 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |