2021-08-30 15:45:18 +01:00
|
|
|
name: Docker
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- "master"
|
|
|
|
tags:
|
|
|
|
- "v*"
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- "master"
|
|
|
|
|
|
|
|
jobs:
|
2021-08-31 21:51:55 +09:00
|
|
|
build:
|
2021-08-30 15:45:18 +01:00
|
|
|
runs-on: ubuntu-latest
|
2021-08-31 21:51:55 +09:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
architecture: [linux/amd64,linux/arm64,linux/arm/v7]
|
2021-08-30 15:45:18 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2021-08-30 16:25:45 +01:00
|
|
|
with:
|
|
|
|
submodules: "recursive"
|
2021-08-31 21:51:55 +09:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
with:
|
|
|
|
platforms: ${{ matrix.architecture }}
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache/${{ matrix.architecture }}
|
|
|
|
key: ${{ runner.os }}-buildx-${{ matrix.architecture }}-${{ github.sha }}
|
|
|
|
- name: Build
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
platforms: ${{ matrix.architecture }}
|
|
|
|
push: false
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache/${{ matrix.architecture }}
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new/${{ matrix.architecture }},mode=max
|
|
|
|
- name: Move cache
|
|
|
|
run: |
|
|
|
|
rm -rf /tmp/.buildx-cache/${{ matrix.architecture }}
|
|
|
|
mv /tmp/.buildx-cache-new/${{ matrix.architecture }} /tmp/.buildx-cache/${{ matrix.architecture }}
|
|
|
|
|
|
|
|
publish:
|
|
|
|
needs: [build]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
submodules: "recursive"
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Cache arm64 Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache/linux/arm64
|
|
|
|
key: ${{ runner.os }}-buildx-linux/arm64-${{ github.sha }}
|
|
|
|
- name: Cache amd64 Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache/linux/amd64
|
|
|
|
key: ${{ runner.os }}-buildx-linux/amd64-${{ github.sha }}
|
|
|
|
- name: Cache armv7 Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache/linux/arm/v7
|
|
|
|
key: ${{ runner.os }}-buildx-linux/arm/v7-${{ github.sha }}
|
2021-08-30 15:45:18 +01:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v3
|
|
|
|
with:
|
2021-08-31 21:51:55 +09:00
|
|
|
images: revoltchat/client, ghcr.io/revoltchat/client
|
2021-08-30 15:45:18 +01:00
|
|
|
- name: Login to DockerHub
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2021-08-31 21:51:55 +09:00
|
|
|
- name: Login to Github Container Registry
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Publish the Docker images
|
2021-08-30 15:45:18 +01:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
2021-08-31 21:51:55 +09:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
2021-08-30 15:45:18 +01:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2021-08-31 21:51:55 +09:00
|
|
|
cache-from: |
|
|
|
|
type=local,src=/tmp/.buildx-cache/linux/amd64
|
|
|
|
type=local,src=/tmp/.buildx-cache/linux/arm64
|
|
|
|
type=local,src=/tmp/.buildx-cache/linux/arm/v7
|