Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Add container

Add container #1

name: Docker Build & Push
on:
push:
paths-ignore:
- "**.md"
- "docker-compose.yml"
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
restic_version: "0.15.2"
jobs:
restic:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/thesilkky/restic
thesilkky/restic
tags: |
type=schedule,pattern={{date 'YYYYMMDD'}}
type=ref,event=branch
type=ref,event=pr
type=sha
type=sha,format=long
type=semver,pattern={{version}},value=v${{ env.restic_version }}
flavor: |
latest=true
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Docker layers
if: github.event_name != 'pull_request'
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: cinny-${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
cinny-${{ runner.os }}-buildx-
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
build-args: RESTIC_VERSION=${{ env.restic_version }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move Cache
if: github.event_name != 'pull_request'
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache