Simplify and enable caching

This commit is contained in:
Otto Winter 2020-07-14 15:10:26 +02:00
parent 3d78248aaf
commit 01b1b688b1
No known key found for this signature in database
GPG key ID: 48ED2DDB96D7682C
2 changed files with 14 additions and 17 deletions

View file

@ -165,15 +165,12 @@ jobs:
if [[ "${{ matrix.build_type }}" == "hassio" ]]; then if [[ "${{ matrix.build_type }}" == "hassio" ]]; then
build_from="esphome/esphome-hassio-base-${{ matrix.arch }}:${base_version}" build_from="esphome/esphome-hassio-base-${{ matrix.arch }}:${base_version}"
build_to="esphome/esphome-hassio-${{ matrix.arch }}" build_to="${{ github.repository }}-hassio-${{ matrix.arch }}"
dockerfile="docker/Dockerfile.hassio" dockerfile="docker/Dockerfile.hassio"
else else
build_from="esphome/esphome-base-${{ matrix.arch }}:${base_version}" build_from="esphome/esphome-base-${{ matrix.arch }}:${base_version}"
build_to="esphome/esphome-${{ matrix.arch }}" build_to="${{ github.repository }}-${{ matrix.arch }}"
dockerfile="docker/Dockerfile" dockerfile="docker/Dockerfile"
if [[ "${{ matrix.arch }}" == "amd64" ]]; then
build_to="esphome/esphome"
fi
fi fi
# Set env variables so these values don't need to be calculated again # Set env variables so these values don't need to be calculated again
@ -190,6 +187,9 @@ jobs:
--build-arg "BUILD_VERSION=${TAG}" \ --build-arg "BUILD_VERSION=${TAG}" \
--tag "${IMAGE}" \ --tag "${IMAGE}" \
--file "${DOCKERFILE}" \ --file "${DOCKERFILE}" \
--cache-from "${{ github.repository }}:latest"
--cache-from "${{ github.repository }}:beta"
--cache-from "${{ github.repository }}:dev"
. .
- name: Log in to docker hub - name: Log in to docker hub
env: env:
@ -213,7 +213,7 @@ jobs:
run: docker login -u "${DOCKER_USER}" -p "${DOCKER_PASSWORD}" run: docker login -u "${DOCKER_USER}" -p "${DOCKER_PASSWORD}"
- name: "Create the manifest" - name: "Create the manifest"
run: | run: |
REPO=esphome/esphome REPO=${{ github.repository }}
TAG="dev" TAG="dev"
docker manifest create ${REPO}:${TAG} \ docker manifest create ${REPO}:${TAG} \
@ -221,6 +221,4 @@ jobs:
${REPO}-amd64:${TAG} \ ${REPO}-amd64:${TAG} \
${REPO}-armv7:${TAG} \ ${REPO}-armv7:${TAG} \
${REPO}-i386:${TAG} ${REPO}-i386:${TAG}
echo "::set-env name=TAG::${TAG}" docker push ${REPO}:${TAG}
echo "::set-env name=REPO::${REPO}"
- run: docker push ${REPO}:${TAG}

View file

@ -186,15 +186,12 @@ jobs:
if [[ "${{ matrix.build_type }}" == "hassio" ]]; then if [[ "${{ matrix.build_type }}" == "hassio" ]]; then
build_from="esphome/esphome-hassio-base-${{ matrix.arch }}:${base_version}" build_from="esphome/esphome-hassio-base-${{ matrix.arch }}:${base_version}"
build_to="esphome/esphome-hassio-${{ matrix.arch }}" build_to="${{ github.repository }}-hassio-${{ matrix.arch }}"
dockerfile="docker/Dockerfile.hassio" dockerfile="docker/Dockerfile.hassio"
else else
build_from="esphome/esphome-base-${{ matrix.arch }}:${base_version}" build_from="esphome/esphome-base-${{ matrix.arch }}:${base_version}"
build_to="esphome/esphome-${{ matrix.arch }}" build_to="${{ github.repository }}-${{ matrix.arch }}"
dockerfile="docker/Dockerfile" dockerfile="docker/Dockerfile"
if [[ "${{ matrix.arch }}" == "amd64" ]]; then
build_to="esphome/esphome"
fi
fi fi
# Set env variables so these values don't need to be calculated again # Set env variables so these values don't need to be calculated again
@ -211,6 +208,9 @@ jobs:
--build-arg "BUILD_VERSION=${TAG}" \ --build-arg "BUILD_VERSION=${TAG}" \
--tag "${IMAGE}" \ --tag "${IMAGE}" \
--file "${DOCKERFILE}" \ --file "${DOCKERFILE}" \
--cache-from "${{ github.repository }}:latest"
--cache-from "${{ github.repository }}:beta"
--cache-from "${{ github.repository }}:dev"
. .
- name: Log in to docker hub - name: Log in to docker hub
env: env:
@ -244,7 +244,7 @@ jobs:
run: docker login -u "${DOCKER_USER}" -p "${DOCKER_PASSWORD}" run: docker login -u "${DOCKER_USER}" -p "${DOCKER_PASSWORD}"
- name: "Create the manifest" - name: "Create the manifest"
run: | run: |
REPO=esphome/esphome REPO=${{ github.repository }}
TAG="${GITHUB_REF#v}" TAG="${GITHUB_REF#v}"
docker manifest create ${REPO}:${TAG} \ docker manifest create ${REPO}:${TAG} \
@ -252,9 +252,8 @@ jobs:
${REPO}-amd64:${TAG} \ ${REPO}-amd64:${TAG} \
${REPO}-armv7:${TAG} \ ${REPO}-armv7:${TAG} \
${REPO}-i386:${TAG} ${REPO}-i386:${TAG}
echo "::set-env name=TAG::${TAG}"
echo "::set-env name=REPO::${REPO}" echo "::set-env name=REPO::${REPO}"
- run: docker push ${REPO}:${TAG} docker push ${REPO}:${TAG}
- name: Publish docker beta tag - name: Publish docker beta tag
if: ${{ github.event.release.prerelease) }} if: ${{ github.event.release.prerelease) }}