Skip to content

Commit 8e39761

Browse files
committed
ci: reduce duplication of fips checks
1 parent 19c4e52 commit 8e39761

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

.github/actions/build-docker/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ runs:
133133
cat /tmp/meta.json
134134
135135
if [[ "${{ inputs.publish-image }}" == 'true' ]]; then
136-
SERVICE_SUFFIX=${{ (inputs.service == 'rocketchat' && inputs.type == 'coverage' && (github.event_name == 'release' || github.ref == 'refs/heads/develop')) && '-cov' || ((inputs.service == 'ddp-streamer-service' || inputs.service == 'presence-service') && inputs.type == 'fips' && '-fips' || '') }}
136+
SERVICE_SUFFIX=${{ (inputs.service == 'rocketchat' && inputs.type == 'coverage' && (github.event_name == 'release' || github.ref == 'refs/heads/develop')) && '-cov' || (inputs.type == 'fips' && '-fips' || '') }}
137137
138138
mkdir -p /tmp/manifests/${{ inputs.service }}${SERVICE_SUFFIX}/${{ inputs.arch }}
139139

.github/workflows/ci.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ concurrency:
2020

2121
env:
2222
TOOL_NODE_FLAGS: ${{ vars.TOOL_NODE_FLAGS }}
23+
FIPS_ENABLED_SERVICES: '["ddp-streamer-service","presence-service"]'
2324

2425
jobs:
2526
release-versions:
@@ -318,8 +319,8 @@ jobs:
318319
env:
319320
# add suffix for the extra images with coverage if building for production
320321
DOCKER_TAG_SUFFIX_ROCKETCHAT: ${{ matrix.type == 'coverage' && (github.event_name == 'release' || github.ref == 'refs/heads/develop') && '-cov' || '' }}
321-
DOCKER_TAG_SUFFIX_FIPS: ${{ (matrix.service[0] == 'ddp-streamer-service' || matrix.service[0] == 'presence-service') && matrix.type == 'fips' && '-fips' || '' }}
322-
BUILD_TARGET: ${{ (matrix.service[0] == 'ddp-streamer-service' || matrix.service[0] == 'presence-service') && matrix.type == 'fips' && 'release-fips' || '' }}
322+
DOCKER_TAG_SUFFIX_FIPS: ${{ contains(fromJSON(env.FIPS_ENABLED_SERVICES), matrix.service[0]) && matrix.type == 'fips' && '-fips' || '' }}
323+
BUILD_TARGET: ${{ contains(fromJSON(env.FIPS_ENABLED_SERVICES), matrix.service[0]) && matrix.type == 'fips' && 'release-fips' || '' }}
323324
with:
324325
CR_USER: ${{ secrets.CR_USER }}
325326
CR_PAT: ${{ secrets.CR_PAT }}
@@ -336,8 +337,8 @@ jobs:
336337
if: matrix.service[1] && github.actor != 'dependabot[bot]'
337338
env:
338339
DOCKER_TAG_SUFFIX_ROCKETCHAT: ${{ matrix.type == 'coverage' && '-cov' || '' }}
339-
DOCKER_TAG_SUFFIX_FIPS: ${{ (matrix.service[1] == 'ddp-streamer-service' || matrix.service[1] == 'presence-service') && matrix.type == 'fips' && '-fips' || '' }}
340-
BUILD_TARGET: ${{ (matrix.service[1] == 'ddp-streamer-service' || matrix.service[1] == 'presence-service') && matrix.type == 'fips' && 'release-fips' || '' }}
340+
DOCKER_TAG_SUFFIX_FIPS: ${{ contains(fromJSON(env.FIPS_ENABLED_SERVICES), matrix.service[1]) && matrix.type == 'fips' && '-fips' || '' }}
341+
BUILD_TARGET: ${{ contains(fromJSON(env.FIPS_ENABLED_SERVICES), matrix.service[1]) && matrix.type == 'fips' && 'release-fips' || '' }}
341342
with:
342343
CR_USER: ${{ secrets.CR_USER }}
343344
CR_PAT: ${{ secrets.CR_PAT }}
@@ -355,8 +356,8 @@ jobs:
355356
if: matrix.service[2] && github.actor != 'dependabot[bot]'
356357
env:
357358
DOCKER_TAG_SUFFIX_ROCKETCHAT: ${{ matrix.type == 'coverage' && '-cov' || '' }}
358-
DOCKER_TAG_SUFFIX_FIPS: ${{ (matrix.service[2] == 'ddp-streamer-service' || matrix.service[2] == 'presence-service') && matrix.type == 'fips' && '-fips' || '' }}
359-
BUILD_TARGET: ${{ (matrix.service[2] == 'ddp-streamer-service' || matrix.service[2] == 'presence-service') && matrix.type == 'fips' && 'release-fips' || '' }}
359+
DOCKER_TAG_SUFFIX_FIPS: ${{ contains(fromJSON(env.FIPS_ENABLED_SERVICES), matrix.service[2]) && matrix.type == 'fips' && '-fips' || '' }}
360+
BUILD_TARGET: ${{ contains(fromJSON(env.FIPS_ENABLED_SERVICES), matrix.service[2]) && matrix.type == 'fips' && 'release-fips' || '' }}
360361
with:
361362
CR_USER: ${{ secrets.CR_USER }}
362363
CR_PAT: ${{ secrets.CR_PAT }}
@@ -374,8 +375,8 @@ jobs:
374375
if: matrix.service[3] && github.actor != 'dependabot[bot]'
375376
env:
376377
DOCKER_TAG_SUFFIX_ROCKETCHAT: ${{ matrix.type == 'coverage' && '-cov' || '' }}
377-
DOCKER_TAG_SUFFIX_FIPS: ${{ (matrix.service[3] == 'ddp-streamer-service' || matrix.service[3] == 'presence-service') && matrix.type == 'fips' && '-fips' || '' }}
378-
BUILD_TARGET: ${{ (matrix.service[3] == 'ddp-streamer-service' || matrix.service[3] == 'presence-service') && matrix.type == 'fips' && 'release-fips' || '' }}
378+
DOCKER_TAG_SUFFIX_FIPS: ${{ contains(fromJSON(env.FIPS_ENABLED_SERVICES), matrix.service[3]) && matrix.type == 'fips' && '-fips' || '' }}
379+
BUILD_TARGET: ${{ contains(fromJSON(env.FIPS_ENABLED_SERVICES), matrix.service[3]) && matrix.type == 'fips' && 'release-fips' || '' }}
379380
with:
380381
CR_USER: ${{ secrets.CR_USER }}
381382
CR_PAT: ${{ secrets.CR_PAT }}
@@ -444,10 +445,9 @@ jobs:
444445
# Get image name from docker-compose-ci.yml since rocketchat image is different from service name (rocket.chat)
445446
if [ "$service" == "rocketchat-cov" ]; then
446447
IMAGE=$(docker compose -f docker-compose-ci.yml config --format json 2>/dev/null | jq -r --arg s "rocketchat" '.services[$s].image')-cov
447-
elif [ "$service" == "presence-service-fips" ]; then
448-
IMAGE=$(docker compose -f docker-compose-ci.yml config --format json 2>/dev/null | jq -r --arg s "presence-service" '.services[$s].image')-fips
449-
elif [ "$service" == "ddp-streamer-service-fips" ]; then
450-
IMAGE=$(docker compose -f docker-compose-ci.yml config --format json 2>/dev/null | jq -r --arg s "ddp-streamer-service" '.services[$s].image')-fips
448+
elif [[ "$service" == *"-fips" ]]; then
449+
base_service="${service%-fips}"
450+
IMAGE=$(docker compose -f docker-compose-ci.yml config --format json 2>/dev/null | jq -r --arg s "$base_service" '.services[$s].image')-fips
451451
else
452452
IMAGE=$(docker compose -f docker-compose-ci.yml config --format json 2>/dev/null | jq -r --arg s "$service" '.services[$s].image')
453453
fi

0 commit comments

Comments
 (0)