Skip to content

Commit

Permalink
update ci.yml
Browse files Browse the repository at this point in the history
- fix matrix
- use docker-container driver for buildkit
- always use image=moby/buildkit:v0.12.2
- fixed registry for login to docker hub
- add platform to tag for PRs
  • Loading branch information
mauwii committed Sep 15, 2023
1 parent bec74c1 commit be64ecf
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
strategy:
matrix:
platforms: ${{ github.event_name == 'pull_request' && fromJson(format('["{0}","{1}"]', 'linux/amd64','linux/arm64')) || fromJson('["linux/amd64,linux/arm64"]') }}
from-version: [ '22.04', '20.04' ]

Check failure on line 26 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

26:24 [brackets] too many spaces inside brackets

Check failure on line 26 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

26:41 [brackets] too many spaces inside brackets

Check failure on line 26 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

26:24 [brackets] too many spaces inside brackets

Check failure on line 26 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

26:41 [brackets] too many spaces inside brackets
include:
- from-version: '22.04'
from-version-major: '22'
Expand All @@ -39,7 +40,8 @@ jobs:
services:
registry:
image: registry:2
ports: [5000]
ports:
- 5000:5000
# options: --entrypoint /bin/registry

Check warning on line 45 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

45:9 [comments-indentation] comment not indented like content

Check warning on line 45 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / MegaLinter

45:9 [comments-indentation] comment not indented like content
env:
CACHE_FROM_REGISTRY: docker.io
Expand All @@ -62,9 +64,14 @@ jobs:
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
driver: ${{ github.event_name == 'pull_request' && 'docker' || 'docker-container' }}
driver-opts: ${{ github.event_name == 'pull_request' && 'network=host,image=moby/buildkit:v0.12.2' || '' }}
install: ${{ github.event_name == 'pull_request' && true || false }}
driver: docker-container
# driver: ${{ github.event_name == 'pull_request' && 'docker' || 'docker-container' }}
driver-opts: |
image=moby/buildkit:v0.12.2
${{ github.event_name == 'pull_request' && 'network=host' || '' }}
install: true
# install: ${{ github.event_name == 'pull_request' && 'true' || 'false' }}
platforms: ${{ matrix.platforms }}

# - name: Login to GitHub Container Registry
# uses: docker/[email protected]
Expand All @@ -79,7 +86,7 @@ jobs:
uses: docker/[email protected]
if: vars.DOCKERHUB_USER != ''
with:
registry: ${{ env.CACHE_FROM_REGISTRY }}
registry: docker.io
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
logout: true
Expand All @@ -98,6 +105,7 @@ jobs:
type=raw,value=${{ matrix.from-version }}-${{ github.head_ref || github.ref_name }},priority=600
flavor: |
latest=${{ github.ref == format('refs/heads/{0}', 'main') && matrix.from-version == '22.04' }}
${{ github.event_name == 'pull_request' && format('suffix=-{0}', matrix.platforms) || '' }}
labels: |
org.opencontainers.image.authors=['${{ env.REPOSITORY_LINK }}','${{ github.actor }}']
org.opencontainers.image.description=${{ github.event.repository.description }}
Expand Down Expand Up @@ -134,7 +142,7 @@ jobs:
cache-from: |
${{ format('type=registry,ref={0}:{1}', env.CACHE_FROM_REGISTRY, matrix.from-version) }}
${{ format('type=registry,ref={0}:cache-{1}',env.CACHE_FROM_REGISTRY, matrix.codename) }}
# cache exporter doesn't work with docker driver
# don't export cache on PR
cache-to: ${{ github.event_name != 'pull_request' && format('type=registry,ref={0}:cache-{1},mode=max',env.REGISTRY_IMAGE, matrix.codename) || '' }}
# this will give us some useful information about the build
provenance: mode=max
Expand Down

0 comments on commit be64ecf

Please sign in to comment.