Skip to content

Build, test, and publish #2

Build, test, and publish

Build, test, and publish #2

name: Build, test, and publish
on: [pull_request, push, workflow_dispatch]
jobs:
build-and-test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
DISTRO: [run, tomcat]
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 }}
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY }}
- name: Test
run: ./test.sh
working-directory: test
env:
DISTRO: ${{ matrix.DISTRO }}
PLATFORM: ${{ matrix.PLATFORM }}
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY }}
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
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY }}