CI: use scripts for docker build (#29599)

* use scripts

* remove common

* do login in the workflow

* separate step

* cleanup

* one script is cleaner

* keep it consistent

* review suggestions

* move in ci too

* PR cleanup
This commit is contained in:
Justin Newberry
2023-08-24 16:09:08 -07:00
committed by GitHub
parent 7dae580441
commit 3d9f238bf9
4 changed files with 67 additions and 51 deletions
+4 -14
View File
@@ -5,12 +5,8 @@ on:
workflow_dispatch:
env:
BASE_IMAGE: openpilot-base
DOCKER_REGISTRY: ghcr.io/commaai
DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
BUILD: |
DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $DOCKER_REGISTRY/$BASE_IMAGE:latest -t $BASE_IMAGE:latest -f Dockerfile.openpilot_base .
BUILD: selfdrive/test/docker_build.sh prebuilt
jobs:
build_prebuilt:
@@ -18,7 +14,7 @@ jobs:
runs-on: ubuntu-20.04
if: github.repository == 'commaai/openpilot'
env:
IMAGE_NAME: openpilot-prebuilt
PUSH_IMAGE: true
steps:
- name: Wait for green check mark
if: ${{ github.event_name != 'workflow_dispatch' }}
@@ -31,13 +27,7 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build Docker image
run: |
eval "$BUILD"
DOCKER_BUILDKIT=1 docker build --pull --cache-to type=inline --cache-from $DOCKER_REGISTRY/$IMAGE_NAME:latest -t $DOCKER_REGISTRY/$IMAGE_NAME:latest -f Dockerfile.openpilot .
- name: Push to container registry
- name: Build and Push docker image
run: |
$DOCKER_LOGIN
docker push $DOCKER_REGISTRY/$IMAGE_NAME:latest
docker tag $DOCKER_REGISTRY/$IMAGE_NAME:latest $DOCKER_REGISTRY/$IMAGE_NAME:$GITHUB_SHA
docker push $DOCKER_REGISTRY/$IMAGE_NAME:$GITHUB_SHA
eval "$BUILD"