Dockerhub CI #77
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
name: Dockerhub CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
schedule: | |
# Triggers every week on tuesday night | |
- cron: '0 0 * * 2' | |
env: | |
# Specify which image to build | |
DOCKER_REPO: godatadriven/spark | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image: | |
- | |
SPARK_VERSION: "3.5.3" | |
OPENJDK_VERSION: "17" | |
HADOOP_VERSION: "3" | |
LATEST: "true" | |
- | |
SPARK_VERSION: "3.4.4" | |
OPENJDK_VERSION: "11" | |
HADOOP_VERSION: "3" | |
LATEST: "false" | |
- | |
SPARK_VERSION: "3.3.4" | |
OPENJDK_VERSION: "11" | |
HADOOP_VERSION: "3" | |
LATEST: "false" | |
- | |
SPARK_VERSION: "3.1.3" | |
OPENJDK_VERSION: "11" | |
HADOOP_VERSION: "3.2" | |
LATEST: "false" | |
- | |
SPARK_VERSION: "3.0.3" | |
OPENJDK_VERSION: "11" | |
HADOOP_VERSION: "3.2" | |
LATEST: "false" | |
- | |
SPARK_VERSION: "2.4.8" | |
OPENJDK_VERSION: "8" | |
HADOOP_VERSION: "2.7" | |
LATEST: "false" | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: setup-buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Generate image metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: "${{ env.DOCKER_REPO }}" | |
flavor: | | |
latest=${{ matrix.image.LATEST }} | |
prefix= | |
suffix= | |
tags: | | |
type=semver,pattern={{version}},value=${{ matrix.image.SPARK_VERSION }} | |
type=semver,pattern={{major}}.{{minor}},value=${{ matrix.image.SPARK_VERSION }} | |
labels: | | |
org.opencontainers.image.vendor=Xebia Data, https://xebia.com/ | |
annotations: | | |
org.opencontainers.image.vendor=Xebia Data, https://xebia.com/ | |
- name: Build image | |
id: docker-build | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: false | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
build-args: | | |
HADOOP_VERSION=${{ matrix.image.HADOOP_VERSION }} | |
OPENJDK_VERSION=${{ matrix.image.OPENJDK_VERSION }} | |
SPARK_VERSION=${{ matrix.image.SPARK_VERSION }} | |
labels: ${{ steps.meta.outputs.labels }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
- name: Test image | |
run: | | |
IMAGE_NAME="godatadriven/spark:${{ matrix.image.SPARK_VERSION }}" | |
TEST_IMAGE_NAME="spark-image-tests:${{ matrix.image.SPARK_VERSION }}" | |
docker build \ | |
--file tests/Dockerfile \ | |
--build-arg IMAGE_NAME="${IMAGE_NAME}" \ | |
--tag "${TEST_IMAGE_NAME}" \ | |
./tests/ | |
docker run --rm "${TEST_IMAGE_NAME}" | |
- name: Login to DockerHub | |
if: github.ref == 'refs/heads/master' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB }} | |
- name: Push image | |
# Build and push because of multi platform build | |
if: github.ref == 'refs/heads/master' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
provenance: false | |
sbom: false | |
tags: ${{ steps.meta.outputs.tags }} | |
build-args: | | |
HADOOP_VERSION=${{ matrix.image.HADOOP_VERSION }} | |
OPENJDK_VERSION=${{ matrix.image.OPENJDK_VERSION }} | |
SPARK_VERSION=${{ matrix.image.SPARK_VERSION }} | |
labels: ${{ steps.meta.outputs.labels }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
platforms: linux/amd64,linux/arm64 | |
- name: Report Status | |
if: always() && github.ref == 'refs/heads/master' | |
uses: ravsamhq/notify-slack-action@v2 | |
with: | |
status: ${{ job.status }} | |
notify_when: 'failure' | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GDD_GENERAL_WEBHOOK }} |