Co-authored-by: Tomek Wójcik <labs@tomekwojcik.pl> Co-committed-by: Tomek Wójcik <labs@tomekwojcik.pl>
202 lines
8.0 KiB
YAML
202 lines
8.0 KiB
YAML
name: "CI"
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "development"
|
|
- "public"
|
|
pull_request:
|
|
branches:
|
|
- "development"
|
|
- "public"
|
|
|
|
jobs:
|
|
run-checks:
|
|
name: "Checks"
|
|
runs-on: "ubuntu-latest"
|
|
steps:
|
|
- name: "Checkout the code"
|
|
uses: "actions/checkout@v2"
|
|
- name: "Get run info"
|
|
id: "get-run-info"
|
|
run: |
|
|
set -x
|
|
echo "COMPOSE_PROJECT=${{ vars.COMPOSE_PROJECT_BASE }}-${GITHUB_RUN_NUMBER}" >> $GITHUB_OUTPUT
|
|
- name: "Get build options"
|
|
id: "get-build-options"
|
|
run: |
|
|
set -x
|
|
SHORT_SHA="${GITHUB_SHA::8}"
|
|
BUILD_ARCH="amd64"
|
|
BUILD_PLATFORM="linux/amd64"
|
|
if [ "${RUNNER_ARCH}" = "ARM64" ];then
|
|
BUILD_ARCH="arm64"
|
|
BUILD_PLATFORM="linux/arm64"
|
|
fi
|
|
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT
|
|
echo "BUILD_ARCH=$BUILD_ARCH" >> $GITHUB_OUTPUT
|
|
echo "BUILD_PLATFORM=$BUILD_PLATFORM" >> $GITHUB_OUTPUT
|
|
- name: "Set up Docker Buildx"
|
|
id: "setup-docker-buildx"
|
|
uses: "docker/setup-buildx-action@v3"
|
|
with:
|
|
driver: "remote"
|
|
endpoint: "tcp://builder-01.bthlab:2375"
|
|
platforms: "linux/amd64"
|
|
append: |
|
|
- endpoint: "tcp://builder-mac-01.bthlab:2375"
|
|
platforms: "linux/arm64"
|
|
- name: "Build `postgres` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/postgres/Dockerfile"
|
|
context: "services/"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/postgres:15.13-${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
platforms: "${{ steps.get-build-options.outputs.BUILD_PLATFORM }}"
|
|
cache-from: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket"
|
|
cache-to: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket,mode=max"
|
|
- name: "Build `keycloak` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/keycloak/Dockerfile"
|
|
context: "services/"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/keycloak:22.0.3-${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
platforms: "${{ steps.get-build-options.outputs.BUILD_PLATFORM }}"
|
|
cache-from: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket"
|
|
cache-to: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket,mode=max"
|
|
- name: "Build `rabbitmq` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/rabbitmq/Dockerfile"
|
|
context: "services/"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/rabbitmq:3.10.8-${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
platforms: "${{ steps.get-build-options.outputs.BUILD_PLATFORM }}"
|
|
cache-from: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket"
|
|
cache-to: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket,mode=max"
|
|
- name: "Build `backend-ci` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/backend/Dockerfile"
|
|
context: "services/"
|
|
target: "ci"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/backend:ci-${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
platforms: "${{ steps.get-build-options.outputs.BUILD_PLATFORM }}"
|
|
cache-from: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket"
|
|
cache-to: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket,mode=max"
|
|
- name: "Build `packages-ci` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/packages/Dockerfile"
|
|
context: "services/"
|
|
target: "ci"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/packages:ci-${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
platforms: "${{ steps.get-build-options.outputs.BUILD_PLATFORM }}"
|
|
cache-from: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket"
|
|
cache-to: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket,mode=max"
|
|
- name: "Build `extension-ci` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/extension/Dockerfile"
|
|
context: "services/"
|
|
target: "ci"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/extension:ci-${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
platforms: "${{ steps.get-build-options.outputs.BUILD_PLATFORM }}"
|
|
cache-from: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket"
|
|
cache-to: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket,mode=max"
|
|
- name: "Build `apple-ci` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/apple/Dockerfile"
|
|
context: "services/"
|
|
target: "ci"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/apple:ci-${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
platforms: "${{ steps.get-build-options.outputs.BUILD_PLATFORM }}"
|
|
cache-from: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket"
|
|
cache-to: "type=registry,ref=nexus.bthlab.bthlabs.net:8001/hotpocket,mode=max"
|
|
- name: "Prepare the build"
|
|
id: "prepare"
|
|
env:
|
|
COMPOSE_PROJECT: "${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
run: |
|
|
set -x
|
|
./.gitea/tools/render-docker-compose-ci.sh
|
|
- name: "Run `backend` checks"
|
|
if: "steps.prepare.conclusion == 'success'"
|
|
env:
|
|
COMPOSE_PROJECT: "${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
run: |
|
|
set -x
|
|
docker compose \
|
|
-p "${COMPOSE_PROJECT}" \
|
|
-f "docker-compose.yaml" \
|
|
-f "docker-compose-ci.yaml" \
|
|
-f "docker-compose-ci-${COMPOSE_PROJECT}.yaml" \
|
|
run --rm \
|
|
backend-ci inv ci
|
|
- name: "Run `packages` checks"
|
|
if: "steps.prepare.conclusion == 'success'"
|
|
env:
|
|
COMPOSE_PROJECT: "${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
run: |
|
|
set -x
|
|
docker compose \
|
|
-p "${COMPOSE_PROJECT}" \
|
|
-f "docker-compose.yaml" \
|
|
-f "docker-compose-ci.yaml" \
|
|
-f "docker-compose-ci-${COMPOSE_PROJECT}.yaml" \
|
|
run --rm \
|
|
packages-ci inv ci
|
|
- name: "Run `extension` checks"
|
|
if: "steps.prepare.conclusion == 'success'"
|
|
env:
|
|
COMPOSE_PROJECT: "${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
run: |
|
|
set -x
|
|
docker compose \
|
|
-p "${COMPOSE_PROJECT}" \
|
|
-f "docker-compose.yaml" \
|
|
-f "docker-compose-ci.yaml" \
|
|
-f "docker-compose-ci-${COMPOSE_PROJECT}.yaml" \
|
|
run --rm \
|
|
extension-ci inv ci
|
|
- name: "Run `apple` checks"
|
|
if: "steps.prepare.conclusion == 'success'"
|
|
env:
|
|
COMPOSE_PROJECT: "${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
run: |
|
|
set -x
|
|
docker compose \
|
|
-p "${COMPOSE_PROJECT}" \
|
|
-f "docker-compose.yaml" \
|
|
-f "docker-compose-ci.yaml" \
|
|
-f "docker-compose-ci-${COMPOSE_PROJECT}.yaml" \
|
|
run --rm \
|
|
apple-ci inv ci
|
|
- name: "Clean up"
|
|
if: always()
|
|
env:
|
|
COMPOSE_PROJECT: "${{ steps.get-run-info.outputs.COMPOSE_PROJECT }}"
|
|
run: |
|
|
set -x
|
|
docker compose \
|
|
-p "${COMPOSE_PROJECT}" \
|
|
-f "docker-compose.yaml" \
|
|
-f "docker-compose-ci.yaml" \
|
|
-f "docker-compose-ci-${COMPOSE_PROJECT}.yaml" \
|
|
down --volumes --rmi all || true
|
|
rm -f "docker-compose-ci-${COMPOSE_PROJECT}.yaml" || true
|