Skip to content

Commit

Permalink
feat(ci): use GitHub Actions cache instead of doing that manually
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Aug 26, 2024
1 parent 9e7b4f9 commit afa5c4c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 203 deletions.
10 changes: 5 additions & 5 deletions .github/bin/get-buildx-args
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

# Generate command-line options for docker buildx build

# Load from local cache
# Load from GitHub Actions cache
if [ -n "$MATRIX_ARCHITECTURE" ] ; then
echo --cache-from "type=local,src=/tmp/.buildx-cache/$MATRIX_ARCHITECTURE"
echo --cache-from "type=gha,scope=$MATRIX_ARCHITECTURE"
else
for arch in linux/amd64 linux/arm64 ; do
echo --cache-from "type=local,src=/tmp/.buildx-cache/$arch"
echo --cache-from "type=gha,scope=$arch"
done
fi

Expand All @@ -21,9 +21,9 @@ if [ "$1" != "load" ] ; then
sed -n "s/^LABEL \(org.opencontainers.image.*\)/--annotation index:\1/p" Dockerfile | sed -e "s/\\\$WEBLATE_VERSION/$WEBLATE_VERSION/"
fi

# Write to local cache unless publishing (not compatible with push)
# Write to GitHub Actions cache unless publishing (not compatible with push)
if [ "$1" != "publish" ] ; then
echo --cache-to "type=local,dest=/tmp/.buildx-cache/$MATRIX_ARCHITECTURE,mode=max"
echo --cache-to "type=gha,mode=max,scope=$MATRIX_ARCHITECTURE"
fi

if [ "$1" = "load" ] ; then
Expand Down
122 changes: 26 additions & 96 deletions .github/workflows/bleeding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@ jobs:
MATRIX_ARCHITECTURE: ${{ matrix.architecture }}
steps:
- uses: actions/checkout@v4
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Configure Docker build
Expand All @@ -73,17 +69,13 @@ jobs:
uses: docker/[email protected]
with:
platforms: ${{ matrix.architecture }}
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Configure Docker build
Expand All @@ -109,17 +101,13 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Build the Docker image
Expand Down Expand Up @@ -166,17 +154,13 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Build the Docker image
Expand Down Expand Up @@ -251,17 +235,13 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Build the Docker image
Expand Down Expand Up @@ -336,17 +316,13 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Build the Docker image
Expand Down Expand Up @@ -423,17 +399,13 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Build the Docker image
Expand Down Expand Up @@ -504,17 +476,13 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Build the Docker image
Expand Down Expand Up @@ -590,17 +558,13 @@ jobs:
MATRIX_ARCHITECTURE: ${{ matrix.architecture }}
steps:
- uses: actions/checkout@v4
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Build the Docker image
Expand Down Expand Up @@ -639,17 +603,13 @@ jobs:
MATRIX_ARCHITECTURE: ${{ matrix.architecture }}
steps:
- uses: actions/checkout@v4
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache/${{ matrix.architecture }}
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-${{ matrix.architecture }}
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Build the Docker image
Expand Down Expand Up @@ -690,23 +650,13 @@ jobs:
uses: docker/[email protected]
with:
platforms: all
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache-arm64
with:
path: /tmp/.buildx-cache/linux/arm64
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-linux/arm64
- name: Cache Docker layers
uses: actions/cache@v4
id: cache-amd64
with:
path: /tmp/.buildx-cache/linux/amd64
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-linux/amd64
- name: Adjust bleeding edge image
run: .github/bin/bleeding ${{needs.bleeding.outputs.weblate_sha}} ${{needs.bleeding.outputs.weblate_date}}
- name: Configure Docker build
Expand Down Expand Up @@ -736,23 +686,13 @@ jobs:
uses: docker/[email protected]
with:
platforms: all
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache-arm64
with:
path: /tmp/.buildx-cache/linux/arm64
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-linux/arm64
- name: Cache Docker layers
uses: actions/cache@v4
id: cache-amd64
with:
path: /tmp/.buildx-cache/linux/amd64
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-linux/amd64
- name: DockerHub login
run: echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Adjust bleeding edge image
Expand Down Expand Up @@ -788,23 +728,13 @@ jobs:
uses: docker/[email protected]
with:
platforms: all
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
# renovate: datasource=github-releases depName=docker/buildx
version: v0.16.2
- name: Cache Docker layers
uses: actions/cache@v4
id: cache-arm64
with:
path: /tmp/.buildx-cache/linux/arm64
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-linux/arm64
- name: Cache Docker layers
uses: actions/cache@v4
id: cache-amd64
with:
path: /tmp/.buildx-cache/linux/amd64
key: ${{ runner.os }}-bleeding-${{ github.run_id }}-linux/amd64
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request'}}
uses: docker/login-action@v3
Expand Down
Loading

0 comments on commit afa5c4c

Please sign in to comment.