-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Switch to GitHub Actions for multi-platform docker build * Add CI tests for all flavors
- Loading branch information
Showing
14 changed files
with
189 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
--- | ||
|
||
name: build | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
env: | ||
IMAGE_REPOSITORY: zenika/alpine-chrome | ||
IMAGE_TAG: latest | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
context: | ||
- folder: . | ||
tag: latest | ||
- folder: with-node | ||
tag: with-node | ||
- folder: with-deno | ||
tag: with-deno | ||
- folder: with-chromedriver | ||
tag: with-chromedriver | ||
- folder: with-playwright # needs with-node | ||
tag: with-playwright | ||
- folder: with-puppeteer # needs with-node | ||
tag: with-puppeteer | ||
- folder: with-puppeteer-xvfb # needs with-puppeteer | ||
tag: with-puppeteer-xvfb | ||
- folder: with-selenoid # needs with-chromedriver | ||
tag: with-selenoid | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Get current date | ||
id: date | ||
run: | | ||
echo "::set-output name=date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | ||
- name: Build and export to Docker | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: ${{ matrix.context.folder }} | ||
load: true | ||
build-args: | | ||
BUILD_DATE=${{ steps.date.outputs.date }} | ||
VCS_REF=${{ github.sha }} | ||
tags: ${{ env.IMAGE_REPOSITORY }}:${{ matrix.context.tag }} | ||
|
||
- name: Test | ||
env: | ||
IMAGE_NAME: ${{ env.IMAGE_REPOSITORY }}:${{ matrix.context.tag }} | ||
run: | | ||
docker container run --rm --entrypoint '' ${IMAGE_NAME} cat /etc/alpine-release | ||
docker container run --rm --entrypoint '' ${IMAGE_NAME} chromium-browser --version | ||
mkdir src/ && chmod a+rwX src/ | ||
if [[ '${{ matrix.context.folder }}' == 'with-node' ]]; then | ||
docker container run --rm --entrypoint '' ${IMAGE_NAME} node --version | ||
elif [[ '${{ matrix.context.folder }}' == 'with-deno' ]]; then | ||
docker container run --rm --entrypoint '' ${IMAGE_NAME} deno --version | ||
elif [[ '${{ matrix.context.folder }}' == 'with-chromedriver' ]]; then | ||
docker container run --rm --entrypoint '' ${IMAGE_NAME} chromedriver --version | ||
elif [[ '${{ matrix.context.folder }}' == 'with-playwright' ]]; then | ||
docker container run --rm --volume $PWD:/work --workdir /work ${IMAGE_NAME} | ||
[ -f src/example-chromium.png ] | ||
elif [[ '${{ matrix.context.folder }}' == 'with-puppeteer' ]]; then | ||
docker container run --rm --volume $PWD:/work --workdir /work --cap-add=SYS_ADMIN ${IMAGE_NAME} | ||
[ -f src/devfest.pdf ] | ||
elif [[ '${{ matrix.context.folder }}' == 'with-puppeteer-xvfb' ]]; then | ||
docker container run --rm --volume $PWD:/work --workdir /work --cap-add=SYS_ADMIN ${IMAGE_NAME} | ||
[ -f src/screenshot.png ] | ||
elif [[ '${{ matrix.context.folder }}' == 'with-selenoid' ]]; then | ||
docker container run --rm --entrypoint '' ${IMAGE_NAME} selenoid -version | ||
fi | ||
- name: Compute versioned tag | ||
if: ${{ github.event_name == 'push' }} | ||
id: tag | ||
env: | ||
IMAGE_NAME: ${{ env.IMAGE_REPOSITORY }}:${{ matrix.context.tag }} | ||
CHROMIUM_VERSION_REGEXP: 'Chromium ([0-9]+)\.' | ||
CHROMEDRIVER_VERSION_REGEXP: 'ChromeDriver ([0-9]+)\.' | ||
run: | | ||
CURRENT_CHROMIUM_VERSION=$(docker container run --rm --entrypoint '' ${IMAGE_NAME} chromium-browser --version) | ||
if [[ ${CURRENT_CHROMIUM_VERSION} =~ ${CHROMIUM_VERSION_REGEXP} ]]; then | ||
echo "ℹ Successfully extracted Chromium major version of ${BASH_REMATCH[1]} from '${CURRENT_CHROMIUM_VERSION}'" | ||
else | ||
echo "❌ Cannot extract Chromium major version from '${CURRENT_CHROMIUM_VERSION}'" >&2 | ||
exit 1 | ||
fi | ||
CHROMIUM_VERSION=${BASH_REMATCH[1]} | ||
TAG=${CHROMIUM_VERSION} | ||
if [[ '${{ matrix.context.folder }}' != '.' ]]; then | ||
TAG=${TAG}-${{ matrix.context.tag }} | ||
fi | ||
if [[ '${{ matrix.context.folder }}' == 'with-chromedriver' ]]; then | ||
CURRENT_CHROMEDRIVER_VERSION=$(docker container run --rm --entrypoint "" ${IMAGE_NAME} chromedriver --version) | ||
if [[ ${CURRENT_CHROMEDRIVER_VERSION} =~ ${CHROMEDRIVER_VERSION_REGEXP} ]]; then | ||
CHROMEDRIVER_MAJOR_VERSION=${BASH_REMATCH[1]} | ||
fi | ||
if [ "${CHROMIUM_VERSION}" != "${CHROMEDRIVER_MAJOR_VERSION}" ]; then | ||
echo "Skipping image pushing because of incompatible chromium (${CHROMIUM_VERSION}) and chromedriver (${CHROMEDRIVER_MAJOR_VERSION}) versions" >&2 | ||
exit 1 | ||
fi | ||
elif [[ '${{ matrix.context.folder }}' == 'with-selenoid' ]]; then | ||
CURRENT_SELENOID_VERSION=$(docker container run --rm --entrypoint "" ${IMAGE_NAME} selenoid -version) | ||
TAG=${TAG}-${CURRENT_SELENOID_VERSION:14:4} | ||
fi | ||
echo "::set-output name=value::${TAG}" | ||
- name: Login to DockerHub | ||
if: ${{ github.event_name == 'push' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to GCR | ||
if: ${{ github.event_name == 'push' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: gcr.io | ||
username: _json_key_base64 | ||
password: ${{ secrets.GCR_JSON_KEY }} | ||
|
||
- name: Login to US GCR | ||
if: ${{ github.event_name == 'push' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: us.gcr.io | ||
username: _json_key_base64 | ||
password: ${{ secrets.GCR_JSON_KEY }} | ||
|
||
- name: Login to EU GCR | ||
if: ${{ github.event_name == 'push' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: eu.gcr.io | ||
username: _json_key_base64 | ||
password: ${{ secrets.GCR_JSON_KEY }} | ||
|
||
- name: Login to Asia GCR | ||
if: ${{ github.event_name == 'push' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: asia.gcr.io | ||
username: _json_key_base64 | ||
password: ${{ secrets.GCR_JSON_KEY }} | ||
|
||
- name: Build and push | ||
if: ${{ github.event_name == 'push' }} | ||
env: | ||
IMAGE_NAME: ${{ env.IMAGE_REPOSITORY }}:${{ matrix.context.tag }} | ||
IMAGE_VERSIONED_NAME: ${{ env.IMAGE_REPOSITORY }}:${{ steps.tag.outputs.value }} | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: ${{ matrix.context.folder }} | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: | | ||
BUILD_DATE=${{ steps.date.outputs.date }} | ||
VCS_REF=${{ github.sha }} | ||
tags: | | ||
${{ env.IMAGE_NAME }} | ||
${{ env.IMAGE_VERSIONED_NAME }} | ||
gcr.io/zenika-hub/${{ env.IMAGE_NAME }} | ||
gcr.io/zenika-hub/${{ env.IMAGE_VERSIONED_NAME }} | ||
us.gcr.io/zenika-hub/${{ env.IMAGE_NAME }} | ||
us.gcr.io/zenika-hub/${{ env.IMAGE_VERSIONED_NAME }} | ||
eu.gcr.io/zenika-hub/${{ env.IMAGE_NAME }} | ||
eu.gcr.io/zenika-hub/${{ env.IMAGE_VERSIONED_NAME }} | ||
asia.gcr.io/zenika-hub/${{ env.IMAGE_NAME }} | ||
asia.gcr.io/zenika-hub/${{ env.IMAGE_VERSIONED_NAME }} | ||
push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.