Skip to content

fix

fix #10

Workflow file for this run

name: Build TMFlow Image
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
env:
REGISTRY: ghcr.io
OWNER: collaborativeroboticslab
TMFLOW_URL: ${{ secrets.TMFLOW_URL || vars.TMFLOW_URL }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-tmflow-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
lfs: true
- name: Derive TMFlow tag
id: version
shell: bash
run: |
set -euo pipefail
sanitize_tag() {
local value="$1"
value="${value%.exe}"
value="${value%.zip}"
value="${value// /-}"
value="$(printf '%s' "$value" | tr '[:upper:]' '[:lower:]')"
value="$(printf '%s' "$value" | sed -E 's/[^a-z0-9._-]+/-/g; s/^-+//; s/-+$//; s/-+/-/g')"
printf '%s' "$value"
}
remote_archive_name() {
if [[ -z "${{ env.TMFLOW_URL }}" ]]; then
return 0
fi
curl -I -L -sS "${{ env.TMFLOW_URL }}" \
| tr -d '\r' \
| sed -n 's/^content-disposition:.*filename="\([^"]*\)".*/\1/p' \
| head -n 1 || true
}
tmflow_file="$(find exe -maxdepth 1 -type f -iname 'TMFlow*.exe' | sort | head -n 1 || true)"
tmflow_tag="latest"
has_tmflow_source="false"
if [[ -n "$tmflow_file" ]]; then
tmflow_tag="$(sanitize_tag "$(basename "$tmflow_file")")"
has_tmflow_source="true"
else
remote_name="$(remote_archive_name)"
if [[ -n "$remote_name" ]]; then
tmflow_tag="$(sanitize_tag "$remote_name")"
has_tmflow_source="true"
fi
fi
{
echo "tmflow_tag=$tmflow_tag"
echo "has_tmflow_source=$has_tmflow_source"
} >> "$GITHUB_OUTPUT"
- name: Set up QEMU
if: steps.version.outputs.has_tmflow_source == 'true'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: steps.version.outputs.has_tmflow_source == 'true'
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: steps.version.outputs.has_tmflow_source == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_PAT }}
- name: Extract Docker metadata
if: steps.version.outputs.has_tmflow_source == 'true'
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.OWNER }}/omron_win_software-tmflow
tags: |
type=raw,value=latest
type=sha
type=raw,value=${{ steps.version.outputs.tmflow_tag }}
- name: Build and Push TMFlow Image
if: steps.version.outputs.has_tmflow_source == 'true'
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.tmflow
platforms: linux/amd64
build-args: |
TMFLOW_URL=${{ env.TMFLOW_URL }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Skip TMFlow image build
if: steps.version.outputs.has_tmflow_source != 'true'
run: echo "Skipping TMFlow image build because no local TMFlow executable or TMFLOW_URL is available."