ci: try to improve cache performance #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build current image | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
paths-ignore: | |
- '*.md' | |
- 'LICENSE' | |
pull_request: | |
branches: | |
- main | |
- dev | |
paths-ignore: | |
- '*.md' | |
- 'LICENSE' | |
jobs: | |
publish: | |
runs-on: self-hosted | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm/v7 | |
- linux/arm64 | |
steps: | |
- name: Set Swap Space | |
uses: pierotofy/set-swap-space@v1 | |
with: | |
swap-size-gb: 10 | |
- run: | | |
# Workaround for https://github.com/rust-lang/cargo/issues/8719 | |
sudo mkdir -p /var/lib/docker | |
sudo mount -t tmpfs -o size=10G none /var/lib/docker | |
sudo systemctl restart docker | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/defguard/gateway | |
tags: | | |
type=ref,event=branch | |
type=raw,value=current | |
type=sha | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build container | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |