Skip to content

Commit

Permalink
Try new buildx actions
Browse files Browse the repository at this point in the history
Signed-off-by: miigotu <[email protected]>

Cache docker layers

Signed-off-by: miigotu <[email protected]>
  • Loading branch information
miigotu committed Mar 21, 2021
1 parent ee94c77 commit 4aae8de
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 76 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/build_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: ci

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
ShellCheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: ShellCheck Depends
uses: ludeeus/action-shellcheck@master
Docker:
name: Docker
runs-on: ubuntu-latest
needs: ShellCheck
steps:
- name: Checkout
if: success()
id: checkout
uses: actions/checkout@v2
- name: Set up QEMU
if: success()
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
if: success()
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Prepare
if: success()
id: prepare
run: |
echo ::set-output name=docker_platforms::linux/amd64,linux/386
echo ::set-output name=docker_username::miigotu
echo ::set-output name=github_image::${{ steps.prepare.outputs.github_image }}
VERSION_TAG=${GITHUB_REF#refs/*/}
echo ::set-output name=version::${VERSION_TAG%/merge}
# - name: Login to DockerHub
# if: success()
# id: login_docker
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: success()
id: login_github
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ steps.prepare.outputs.docker_username }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (master)
if: success() && steps.prepare.outputs.version == 'master' && github.event_name != 'pull_request'
id: build_push_master
uses: docker/build-push-action@v2
with:
context: .
platforms: ${{ steps.prepare.outputs.docker_platforms }}
push: true
tags: |
${{ steps.prepare.outputs.github_image }}:master
${{ steps.prepare.outputs.github_image }}:latest
- name: Build and push (development)
if: success() && steps.prepare.outputs.version != 'master' && github.event_name != 'pull_request'
id: build_push_development
uses: docker/build-push-action@v2
with:
context: .
platforms: ${{ steps.prepare.outputs.docker_platforms }}
push: true
tags: |
${{ steps.prepare.outputs.github_image }}:${{ steps.prepare.outputs.version }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
76 changes: 0 additions & 76 deletions .github/workflows/test_and_build.yaml

This file was deleted.

0 comments on commit 4aae8de

Please sign in to comment.