Skip to content

🔧 fix(sources): set envvar #10

🔧 fix(sources): set envvar

🔧 fix(sources): set envvar #10

name: build-image-develop
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- .github/workflows/build-image-develop.yaml
- docker/all.dockerfile
- docker/raspi.dockerfile
- sources/**
jobs:
init:
name: 🧐 Inintialize
runs-on: ubuntu-24.04-arm
outputs:
step_init: ${{ steps.check_flag.outputs.step_init }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check for --no-ci flag in commit message
id: check_flag
run: |
echo "Checking commit message for --no-ci flag..."
if [ "$(echo '${{ github.event.head_commit.message }}' | grep -c -- '--no-ci')" -gt 0 ]; then
echo "step_init=false" >> $GITHUB_OUTPUT
else
echo "step_init=true" >> $GITHUB_OUTPUT
fi
build-and-testing:
name: 🏗️ Build and testing
needs: init
if: ${{ needs.init.outputs.step_init == 'true' }}
runs-on:
labels: r4spi-microk8s # Self-hosted ARM64 runner
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract short SHA
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
- name: Set the version with short SHA
run: echo "${{ env.SHORT_SHA }}" > ./sources/version
- name: Build/Publish as GitHub Package
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/all.dockerfile
platforms: linux/arm64
push: true
provenance: false
tags: |
ghcr.io/${{ github.repository }}-dev:latest
ghcr.io/${{ github.repository }}-dev:${{ env.SHORT_SHA }}
- name: Test image default
run: |
docker run -i ghcr.io/${{ github.repository }}-dev:${{ env.SHORT_SHA }}
- name: Test image version
run: |
docker run -i ghcr.io/${{ github.repository }}-dev:${{ env.SHORT_SHA }} python main.py --version