Skip to content

Commit

Permalink
add depot builds for both ARM and AMD archs
Browse files Browse the repository at this point in the history
  • Loading branch information
nyakiomaina committed Nov 26, 2024
1 parent d636683 commit 6bc1d9a
Showing 1 changed file with 70 additions and 29 deletions.
99 changes: 70 additions & 29 deletions .github/workflows/depot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,74 @@ jobs:
build:
name: Depot Build
runs-on: depot-ubuntu-22.04-4

strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Depot CLI
uses: depot/setup-action@v1
env:
DEPOT_TOKEN: ${{ secrets.DEPOT_API_TOKEN }}

- name: Build and Load Docker Image with Depot
run: |
depot build . \
--project hs0gfs4l0l \
--file Dockerfile \
--tag ${{ env.REGISTRY }}/${{ github.repository }}:latest \
--platform linux/amd64 \
--build-arg RELEASE=--release \
--build-arg ARCH=amd64 \
--build-arg RELEASE_DIR=release \
--load
env:
DEPOT_TOKEN: ${{ secrets.DEPOT_API_TOKEN }}
- name: Checkout Repository
uses: actions/checkout@v2
- name: Login to Github Container Registry (GHCR)
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Depot CLI
uses: depot/setup-action@v1
env:
DEPOT_TOKEN: ${{ secrets.DEPOT_API_TOKEN }}
- name: Build and Push Docker Image with Depot
run: |
depot build . \
--project hs0gfs4l0l \
--file Dockerfile \
--tag ${{ env.REGISTRY }}/${{ github.repository }}:${{ matrix.arch }}-latest \
--platform linux/${{ matrix.arch }} \
--build-arg ARCH=${{ matrix.arch }} \
--cache-from type=gha,scope=build-${{ matrix.arch }} \
--cache-to type=gha,mode=max,scope=build-${{ matrix.arch }} \
--push
env:
DEPOT_TOKEN: ${{ secrets.DEPOT_API_TOKEN }}

manifest:
name: Create and Push Multi-Architecture Manifest
runs-on: ubuntu-latest
needs: build
steps:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Install jq
run: sudo apt-get install -y jq
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull Architecture-Specific Images
run: |
docker pull --platform linux/amd64 ${{ env.REGISTRY }}/${{ github.repository }}:amd64-latest
docker pull --platform linux/arm64 ${{ env.REGISTRY }}/${{ github.repository }}:arm64-latest
- name: Extract Digests from Manifests
run: |
AMD64_DIGEST=$(docker manifest inspect ${{ env.REGISTRY }}/${{ github.repository }}:amd64-latest | jq -r '.manifests[] | select(.platform.architecture == "amd64") | .digest')
ARM64_DIGEST=$(docker manifest inspect ${{ env.REGISTRY }}/${{ github.repository }}:arm64-latest | jq -r '.manifests[] | select(.platform.architecture == "arm64") | .digest')
echo "AMD64 Digest: $AMD64_DIGEST"
echo "ARM64 Digest: $ARM64_DIGEST"
echo "AMD64_DIGEST=${AMD64_DIGEST}" >> $GITHUB_ENV
echo "ARM64_DIGEST=${ARM64_DIGEST}" >> $GITHUB_ENV
- name: Create and Push Docker Manifest
run: |
docker manifest create ${{ env.REGISTRY }}/${{ github.repository }}:latest \
${{ env.REGISTRY }}/${{ github.repository }}@${{ env.AMD64_DIGEST }} \
${{ env.REGISTRY }}/${{ github.repository }}@${{ env.ARM64_DIGEST }}
docker manifest annotate ${{ env.REGISTRY }}/${{ github.repository }}:latest ${{ env.REGISTRY }}/${{ github.repository }}@${{ env.AMD64_DIGEST }} --arch amd64
docker manifest annotate ${{ env.REGISTRY }}/${{ github.repository }}:latest ${{ env.REGISTRY }}/${{ github.repository }}@${{ env.ARM64_DIGEST }} --arch arm64
docker manifest push ${{ env.REGISTRY }}/${{ github.repository }}:latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled

0 comments on commit 6bc1d9a

Please sign in to comment.