-
Notifications
You must be signed in to change notification settings - Fork 3
146 lines (127 loc) · 4.53 KB
/
dockerhub_ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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:
# Specify which tags to build
DOCKER_TAG:
- "3.5.3,3.5,latest"
- "3.4.4,3.4"
- "3.3.4,3.3"
- "3.1.3,3.1"
- "3.0.3,3.0"
- "2.4.8,2.4"
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Parse args
id: args
run: |
DOCKER_TAG="${{ matrix.DOCKER_TAG }}"
# Manipulate DOCKER_TAG to create build args
SPARK_MAJOR_VERSION=${DOCKER_TAG:0:1}
SPARK_MAJOR_MINOR_VERSION=${DOCKER_TAG:0:3}
if [[ ${SPARK_MAJOR_MINOR_VERSION} = "3.5" || ${DOCKER_TAG} == "latest" ]]; then
OPENJDK_VERSION=17
HADOOP_VERSION=3
elif [[ ${SPARK_MAJOR_MINOR_VERSION} = "3.3" || ${SPARK_MAJOR_MINOR_VERSION} = "3.4" ]]; then
OPENJDK_VERSION=11
HADOOP_VERSION=3
elif [ ${SPARK_MAJOR_VERSION} = "3" ]; then
OPENJDK_VERSION=11
HADOOP_VERSION=3.2
else
OPENJDK_VERSION=8
HADOOP_VERSION=2.7
fi
BUILD_ARGS="OPENJDK_VERSION=${OPENJDK_VERSION}
HADOOP_VERSION=${HADOOP_VERSION}
SPARK_VERSION=${DOCKER_TAG%%,*}"
# No modification needed beyond this point
BUILD_ARGS="${BUILD_ARGS//'%'/'%25'}"
BUILD_ARGS="${BUILD_ARGS//$'\n'/'%0A'}"
BUILD_ARGS="${BUILD_ARGS//$'\r'/'%0D'}"
echo "::set-output name=build_args::$BUILD_ARGS"
- name: Prepare
id: prep
run: |
DOCKER_TAG="${{ matrix.DOCKER_TAG }}"
DOCKER_IMAGE_NAME="$DOCKER_REPO:${DOCKER_TAG%%,*}"
echo ::set-output name=image_name::${DOCKER_IMAGE_NAME}
TAGS="$DOCKER_REPO:${DOCKER_TAG//,/,$DOCKER_REPO:}"
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: false
load: true
tags: ${{ steps.prep.outputs.tags }}
build-args: |
${{ steps.args.outputs.build_args }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Test image
env:
IMAGE_NAME: ${{ steps.prep.outputs.image_name }}
run: |
if [[ -f "docker-compose.test.yml" ]]; then
docker compose --file docker-compose.test.yml build
docker compose --file docker-compose.test.yml run sut
fi
- name: Login to DockerHub
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v1
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@v4
with:
context: .
file: ./Dockerfile
push: true
provenance: false
sbom: false
tags: ${{ steps.prep.outputs.tags }}
build-args: |
${{ steps.args.outputs.build_args }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
platforms: linux/amd64,linux/arm64
- name: Report Status
if: always() && github.ref == 'refs/heads/master'
uses: ravsamhq/notify-slack-action@master
with:
status: ${{ job.status }}
notify_when: 'failure'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GDD_GENERAL_WEBHOOK }}