Skip to content

Build, test, and publish #10

Build, test, and publish

Build, test, and publish #10

name: Build, test, and publish
on:
workflow_dispatch:
inputs:
distribution:
description: 'The distribution to build'
required: true
default: '["run"]'
options:
- '["run"]'
- '["tomcat"]'
- '["run", "tomcat"]'
platform:
description: 'The platform to build for'
required: true
default: '["amd64"]'
options:
- '["amd64"]'
- '["arm64"]'
- '["amd64", "arm64"]'
version:
description: 'The version to build'
required: false
default: '1.0.0-beta-3'
snapshot:
description: 'Build a snapshot version'
type: boolean
required: false
default: true
release:
repositories:
- 'operaton/operaton'
types: [published]
jobs:
build-and-test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
DISTRO: ${{ fromJson(github.event.inputs.distribution || '["run", "tomcat"]') }}
PLATFORM: ${{ fromJson(github.event.inputs.platform || '["amd64", "arm64"]') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: ${{ matrix.PLATFORM != 'amd64' }}
with:
platforms: ${{ matrix.PLATFORM }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Expose GitHub Runtime
uses: actions/github-script@v7
with:
script: |
Object.keys(process.env).forEach(function (key) {
if (key.startsWith('ACTIONS_')) {
core.info(`${key}=${process.env[key]}`);
core.exportVariable(key, process.env[key]);
}
});
- name: Build
run: ./pipeline.sh
env:
DISTRO: ${{ matrix.DISTRO }}
PLATFORM: ${{ matrix.PLATFORM }}
VERSION: ${{ github.event.inputs.version || '' }}
SNAPSHOT: ${{ github.event.inputs.snapshot || '' }}
IMAGE_REPO_OPERATON: ${{ vars.IMAGE_REPO_OPERATON }}
IMAGE_REPO_TOMCAT: ${{ vars.IMAGE_REPO_TOMCAT }}
- name: Test
run: ./test.sh
working-directory: test
env:
DISTRO: ${{ matrix.DISTRO }}
PLATFORM: ${{ matrix.PLATFORM }}
VERSION: ${{ github.event.inputs.version || '' }}
SNAPSHOT: ${{ github.event.inputs.snapshot || '' }}
IMAGE_REPO_OPERATON: ${{ vars.IMAGE_REPO_OPERATON }}
IMAGE_REPO_TOMCAT: ${{ vars.IMAGE_REPO_TOMCAT }}
publish:
runs-on: ubuntu-20.04
needs: build-and-test
strategy:
matrix:
DISTRO: [run, tomcat]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Expose GitHub Runtime
uses: actions/github-script@v7
with:
script: |
Object.keys(process.env).forEach(function (key) {
if (key.startsWith('ACTIONS_')) {
core.info(`${key}=${process.env[key]}`);
core.exportVariable(key, process.env[key]);
}
});
- name: Publish multi-platform images
run: ./release.sh
env:
DISTRO: ${{ matrix.DISTRO }}
PLATFORMS: linux/arm64,linux/amd64
VERSION: ${{ github.event.inputs.version || '' }}
SNAPSHOT: ${{ github.event.inputs.snapshot || '' }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
IMAGE_REPO_OPERATON: ${{ vars.IMAGE_REPO_OPERATON }}
IMAGE_REPO_TOMCAT: ${{ vars.IMAGE_REPO_TOMCAT }}