Skip to content

Add readme

Add readme #7

name: Generate and upload WinCC OA image
on:
push:
branches: [ "main", "release/*", "develop", "develop/*" ]
# pull_request:
# branches: [ "main", "release/*", "develop", "develop/*" ]
release:
types: [published]
jobs:
get_environment:
runs-on: ubuntu-latest
steps:
- name: Define the used environment
id: env_check
run: |
ENV_NAME=staging
if [[ "${{ github.event_name }}" == "release" ]]; then
ENV_NAME=staging
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
ENV_NAME=staging
else
ENV_NAME=staging
fi
echo "Chosen environment: ${ENV_NAME}"
echo "env_name=${ENV_NAME}" >> $GITHUB_OUTPUT
outputs:
env_name: ${{ steps.env_check.outputs.env_name }}
generate-winccoa-image:
needs: [get_environment]
runs-on: ubuntu-latest
environment:
name: ${{ needs.get_environment.outputs.env_name }}
steps:
- name: Set up Git repository
uses: actions/checkout@v3
- name: Download current WinCC OA version
env:
ETM_USERNAME: ${{ secrets.ETM_USERNAME }}
ETM_PASSWORD: ${{ secrets.ETM_PASSWORD }}
run: scripts/download.sh
- name: Extract version information
id: get_version
run: |
zip_file=$(ls *.zip | head -n 1)
if [ -f "$zip_file" ]; then
echo "ZIP file found: $zip_file"
[[ $zip_file =~ ([0-9]+)\.([0-9]+)_linux_debian_x86_64_P([0-9]+)\.?([0-9]*)\.zip ]]
major_version=${BASH_REMATCH[1]}
minor_version=${BASH_REMATCH[2]}
patch_version=$(echo ${BASH_REMATCH[3]} | sed 's/^0*//') # Remove leading zeros
revision=${BASH_REMATCH[4]#\.} # Remove leading dot from the revision
if [ "$revision" != "0" ] && [ ! -z "$revision" ]; then
version_string="$major_version.$minor_version.$patch_version.$revision"
else
version_string="$major_version.$minor_version.$patch_version"
fi
echo "Version info found: ${version_string}"
echo "major_version=${major_version}" >> $GITHUB_OUTPUT
echo "minor_version=${minor_version}" >> $GITHUB_OUTPUT
echo "patch_version=${patch_version}" >> $GITHUB_OUTPUT
echo "revision=${revision}" >> $GITHUB_OUTPUT
echo "version=${version_string}" >> $GITHUB_OUTPUT
else
echo "No ZIP file found"
exit 1
fi
- name: Unzip data
run: |
mkdir data && cd data && \
unzip ../*.zip
- name: Prepare data for Docker image build
run: |
# copy files provided from WinCC OA package for our custom Docker build
cp data/docker-entrypoint.sh data/Dockerfile build-docker/
# patch Dockerfile so it does not copy and install the packages, but only does preparation
scripts/patchDockerfile.sh build-docker/Dockerfile
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker build setup
working-directory: ./build-docker
run: |
docker network create winccoarepo
docker compose up -d
# wait until repo data is generated
docker compose wait create-repo
- name: Docker build preparation image
working-directory: ./build-docker
run: |
DOCKER_BUILDKIT=0 docker build --no-cache --network=winccoarepo -t winccoaprepare:temp .
- name: Docker build and push images
working-directory: ./build-docker
run: |
# specify targets from Dockerfile_install here
for target in api server uiserver; do
tag_suffix=${target}
image_name="${DOCKER_IMAGE}:v${{ steps.get_version.outputs.version }}-${tag_suffix}"
DOCKER_BUILDKIT=0 docker build --network=winccoarepo --build-arg BASE_IMAGE=winccoaprepare:temp --target winccoa${target} --tag ${image_name} -f Dockerfile_install .
docker push ${image_name}
done
env:
DOCKER_IMAGE: ${{ vars.DOCKER_IMAGE }}
- name: Docker build teardown
working-directory: ./build-docker
run: |
docker compose down
docker network rm winccoarepo