Skip to content

chore: Fixes typo and modify the .dockerignore #8

chore: Fixes typo and modify the .dockerignore

chore: Fixes typo and modify the .dockerignore #8

Workflow file for this run

name: Docker
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
workflow_dispatch:
inputs:
image_name:
description: 'Docker image name'
required: false
default: ''
image_tag:
description: 'Docker image tag'
required: false
default: ''
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
IMAGE_NAME:
IMAGE_TAG:
steps:
- uses: actions/checkout@v4
- name: Prepare environment
run: |
function get_name() {
if [ -n "${{ inputs.image_name }}" ]; then
echo "${{ inputs.image_name }}"
else
echo "${{ vars.DOCKER_IMAGE_NAME }}"
fi
}
function get_tag() {
if [ -n "${{ inputs.image_tag }}" ]; then
echo "${{ inputs.image_tag }}"
else
local tag version
tag=$(git describe --tags --abbrev=0 2>/dev/null)
if [ -n "$tag" ]; then
version=$(echo $tag | grep -oP '^v\d+(\.\d+)*$' | sed 's/^v//')
if [ -n "$version" ]; then
tag="$version"
fi
fi
if [ -z "$tag" ]; then
tag="latest"
fi
echo "$tag"
fi
}
IMAGE_NAME="$(get_name)"
IMAGE_TAG="$(get_tag)"
echo "IMAGE_NAME=$IMAGE_NAME" >> "$GITHUB_ENV"
echo "IMAGE_TAG=$IMAGE_TAG" >> "$GITHUB_ENV"
- name: Build image
run: |
echo "Building image ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}"
docker build -t '${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}' .
- name: Export image
run: docker save '${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}' -o image.tar
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: image_${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}
path: image.tar
retention-days: 1