Skip to content

Commit

Permalink
Actions update and small fixes (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
docgalaxyblock authored Sep 18, 2024
1 parent 5005575 commit 4505c4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ concurrency:
permissions:
packages: write



jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -42,11 +44,15 @@ jobs:
echo "BUILD_ARCH=${build_arch//\//-}" >> ${GITHUB_ENV}
echo "REPOSITORY_LC=${REPOSITORY,,}" >> ${GITHUB_ENV}
# Get the repository's code
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v3

- uses: actions/setup-python@v5

- uses: pre-commit/[email protected]

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand All @@ -71,6 +77,7 @@ jobs:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
Expand All @@ -80,12 +87,12 @@ jobs:

- name: Build and push
id: build-and-push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
platforms: ${{ matrix.docker_build_arch }}
no-cache: ${{ inputs.clean_build == true }}
no-cache: ${{ inputs.clean_build == true || false }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ env.REPOSITORY_LC }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
Expand All @@ -96,6 +103,7 @@ jobs:
mkdir -p /tmp/digests
digest="${{ steps.build-and-push.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
Expand All @@ -104,6 +112,8 @@ jobs:
if-no-files-found: error
retention-days: 1



merge:
runs-on: ubuntu-latest
needs:
Expand All @@ -114,14 +124,17 @@ jobs:
REPOSITORY: '${{ github.repository }}'
run: |
echo "REPOSITORY_LC=${REPOSITORY,,}" >> ${GITHUB_ENV}
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand All @@ -137,17 +150,20 @@ jobs:
type=semver,pattern={{major}}
type=sha
images: ghcr.io/${{ env.REPOSITORY_LC }}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/${{ env.REPOSITORY_LC }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/${{ env.REPOSITORY_LC }}:${{ steps.meta.outputs.version }}
10 changes: 5 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Get a base image
FROM docker.io/ros:noetic-ros-base-focal as base
FROM docker.io/ros:noetic-ros-base-focal AS base
ENV DEBIAN_FRONTEND=noninteractive

# Install required packages
Expand All @@ -20,7 +20,7 @@ COPY --link ./docker/assets/nginx.conf /etc/nginx/conf.d/default.conf
RUN rosdep update --rosdistro $ROS_DISTRO

# First stage: Pull the git and all submodules, other stages depend on it
FROM base as fetch
FROM base AS fetch

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -33,7 +33,7 @@ RUN git submodule update --init --recursive

# Get slic3r_coverage_planner and build that. We will pull the finished install folder from this.
# This stage should cache most of the time, that's why it's not derived from the fetch stage, but copies stuff instead.
FROM base as slic3r
FROM base AS slic3r

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -53,7 +53,7 @@ RUN bash -c "source /opt/ros/$ROS_DISTRO/setup.bash && source /opt/slic3r_covera
# If the package list is the same as last time, the apt install step is cached as well which saves a lot of time.
# Since the list gets sorted, it will be the same each time and the cache will know that by file checksum in the COPY command.
# We can't use this stage as base for the next, because this stage is run every time and would therefore invalidate the cache of the next stage.
FROM fetch as dependencies
FROM fetch AS dependencies

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -67,7 +67,7 @@ RUN apt-get update && \


# We can't derive this from "dependencies" because "dependencies" will be rebuilt every time, but apt install should only be done if needed
FROM base as assemble
FROM base AS assemble

ENV DEBIAN_FRONTEND=noninteractive

Expand Down

0 comments on commit 4505c4d

Please sign in to comment.