2020-11-13 14:32:18 -05:00
|
|
|
name: Docker
|
|
|
|
|
2020-11-27 04:38:38 -05:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
pull_request:
|
2021-01-21 19:10:17 -05:00
|
|
|
types: [synchronize, opened, reopened, ready_for_review]
|
2020-11-13 14:32:18 -05:00
|
|
|
|
|
|
|
jobs:
|
2023-04-14 11:23:00 -04:00
|
|
|
config:
|
|
|
|
runs-on: "ubuntu-latest"
|
|
|
|
outputs:
|
|
|
|
has-secrets: ${{ steps.check.outputs.has-secrets }}
|
|
|
|
steps:
|
|
|
|
- name: "Check for secrets"
|
|
|
|
id: check
|
2024-01-24 15:27:48 -05:00
|
|
|
env:
|
|
|
|
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
|
|
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
2023-04-14 11:23:00 -04:00
|
|
|
run: |
|
2024-01-24 15:27:48 -05:00
|
|
|
if [[ -n "$DOCKERHUB_USER" && -n "$DOCKERHUB_TOKEN" ]]; then
|
|
|
|
echo "has-secrets=true" >> "$GITHUB_ENV"
|
2023-06-16 15:55:35 -04:00
|
|
|
echo "has secrets!"
|
|
|
|
else
|
2024-01-24 15:27:48 -05:00
|
|
|
echo "has-secrets=false" >> "$GITHUB_ENV"
|
2023-06-16 15:55:35 -04:00
|
|
|
echo "no secrets!"
|
2023-04-14 11:23:00 -04:00
|
|
|
fi
|
|
|
|
docker-build:
|
|
|
|
needs: config
|
2024-01-24 15:27:48 -05:00
|
|
|
if: needs.config.outputs.has-secrets == 'true'
|
2021-02-06 19:25:46 -05:00
|
|
|
name: docker-build
|
2020-11-13 14:32:18 -05:00
|
|
|
runs-on: ubuntu-latest
|
2024-01-23 16:44:07 -05:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
target: ["dev", "lean", "lean310", "websocket", "dockerize"]
|
|
|
|
platform: ["linux/amd64", "linux/arm64"]
|
2024-01-23 23:30:53 -05:00
|
|
|
exclude:
|
|
|
|
# disabling because slow! no python wheels for arm/py39 and
|
|
|
|
# QEMU is slow!
|
|
|
|
- target: "dev"
|
|
|
|
platform: "linux/arm64"
|
|
|
|
- target: "lean"
|
|
|
|
platform: "linux/arm64"
|
2024-01-23 16:44:07 -05:00
|
|
|
fail-fast: false
|
2020-11-13 14:32:18 -05:00
|
|
|
steps:
|
2021-01-24 02:10:16 -05:00
|
|
|
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
|
2024-01-23 16:44:07 -05:00
|
|
|
uses: actions/checkout@v4
|
2021-01-24 02:10:16 -05:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2024-01-23 16:44:07 -05:00
|
|
|
|
2023-09-25 16:08:21 -04:00
|
|
|
- name: Set up QEMU
|
2024-01-23 16:44:07 -05:00
|
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
|
2023-09-25 16:08:21 -04:00
|
|
|
- name: Set up Docker Buildx
|
2024-01-23 16:44:07 -05:00
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- name: Build Docker Image
|
|
|
|
shell: bash
|
2020-11-13 14:32:18 -05:00
|
|
|
env:
|
|
|
|
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
|
|
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
run: |
|
2024-01-23 16:44:07 -05:00
|
|
|
./scripts/docker_build_push.sh "" ${{ matrix.target }} ${{ matrix.platform }}
|
|
|
|
|
|
|
|
ephemeral-docker-build:
|
|
|
|
needs: config
|
|
|
|
if: needs.config.outputs.has-secrets
|
|
|
|
name: docker-build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
persist-credentials: false
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
2021-02-24 13:50:52 -05:00
|
|
|
|
|
|
|
- name: Build ephemeral env image
|
|
|
|
if: github.event_name == 'pull_request'
|
|
|
|
run: |
|
|
|
|
mkdir -p ./build
|
|
|
|
echo ${{ github.sha }} > ./build/SHA
|
|
|
|
echo ${{ github.event.pull_request.number }} > ./build/PR-NUM
|
2023-09-25 16:08:21 -04:00
|
|
|
docker buildx build --target ci \
|
|
|
|
--load \
|
2024-01-23 16:44:07 -05:00
|
|
|
--cache-from=type=registry,ref=apache/superset:lean \
|
2023-09-25 16:08:21 -04:00
|
|
|
-t ${{ github.sha }} \
|
|
|
|
-t "pr-${{ github.event.pull_request.number }}" \
|
|
|
|
--platform linux/amd64 \
|
|
|
|
--label "build_actor=${GITHUB_ACTOR}" \
|
|
|
|
.
|
2021-02-24 13:50:52 -05:00
|
|
|
docker save ${{ github.sha }} | gzip > ./build/${{ github.sha }}.tar.gz
|
|
|
|
|
|
|
|
- name: Upload build artifacts
|
|
|
|
if: github.event_name == 'pull_request'
|
2024-01-23 16:44:07 -05:00
|
|
|
uses: actions/upload-artifact@v4
|
2021-02-24 13:50:52 -05:00
|
|
|
with:
|
|
|
|
name: build
|
|
|
|
path: build/
|