OpenSlides/.github/workflows/build_images.yml
2022-03-26 06:33:33 +01:00

91 lines
2.7 KiB
YAML

---
name: Build Docker images for all OpenSlides services
on: [push, workflow_dispatch]
env:
IMAGE_VERSION: 4.0.0-beta
TAG_SUFFIX: -$(date +%Y%m%d)-${GITHUB_SHA::7}
jobs:
build:
name: Builds Docker images
runs-on: ubuntu-latest
strategy:
matrix:
service:
- name: openslides-proxy
directory: proxy
- name: openslides-client
directory: openslides-client
- name: openslides-backend
directory: openslides-backend
- name: openslides-datastore-reader
directory: openslides-datastore-service
args:
MODULE: reader
PORT: 9010
- name: openslides-datastore-writer
directory: openslides-datastore-service
args:
MODULE: writer
PORT: 9011
- name: openslides-autoupdate
directory: openslides-autoupdate-service
- name: openslides-auth
directory: openslides-auth-service
- name: openslides-vote
directory: openslides-vote-service
- name: openslides-icc
directory: openslides-icc-service
- name: openslides-media
directory: openslides-media-service
- name: openslides-manage
directory: openslides-manage-service
steps:
- name: Check out code
uses: actions/checkout@v2
with:
submodules: true
- name: Build image
working-directory: ${{ matrix.service.directory }}
env:
DOCKER_BUILDKIT: 1
run: |
if [ "${{ matrix.service.name }}" = "openslides-client" ]
then
eval echo ${IMAGE_VERSION}${TAG_SUFFIX} > client/src/assets/version.txt
fi
if [ "${{ matrix.service.args }}" != "" ]
then
export BUILD_ARGS="--build-arg MODULE=${{ matrix.service.args.MODULE }}
--build-arg PORT=${{ matrix.service.args.PORT }}"
fi
docker build . --tag ${{ matrix.service.name }} $BUILD_ARGS
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" |
docker login ghcr.io --username ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/${{ matrix.service.name }}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag ${{ matrix.service.name }} ${IMAGE_ID}:$(eval echo ${IMAGE_VERSION}${TAG_SUFFIX})
docker tag ${{ matrix.service.name }} ${IMAGE_ID}:latest
docker push ${IMAGE_ID}:$(eval echo ${IMAGE_VERSION}${TAG_SUFFIX})
docker push ${IMAGE_ID}:latest