Skip to content

test

test #12

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
workflow_dispatch:
inputs:
branch-tag:
description: Branch or Tag
required: true
default: 'develop'
workflow_call:
inputs:
branch-tag:
required: true
type: string
default: 'develop'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the Docker image
run: |
pattern="^v[0-9]+\.[0-9]+\.[0-9]+$"
input_branch=${{ github.event.inputs.branch-tag }}
input_commit=${input_branch:-develop}
if [[ $pattern =~ $input_commit ]]; then
tag=${{ github.event.inputs.branch-tag }}
echo "Changed build tag to $tag"
git checkout $tag
else
tag=$(date +%s)
echo "Running build on develop branch"
fi
image_with_tag="ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:$(date +%s)"
docker build . --file Dockerfile --tag $image_with_tag
docker push $image_with_tag