ArchiveBox/.github/workflows/docker.yml

108 lines
3.1 KiB
YAML
Raw Normal View History

name: Build Docker image
2020-11-17 15:57:03 +00:00
on:
2021-02-01 08:09:31 +00:00
workflow_dispatch:
push:
branches:
- '**'
tags:
- 'v*'
# pull_request:
2020-11-17 15:57:03 +00:00
2020-11-28 10:32:38 +00:00
env:
DOCKER_IMAGE: archivebox-ci
2020-11-17 15:57:03 +00:00
jobs:
buildx:
runs-on: ubuntu-latest
steps:
2020-11-22 23:41:22 +00:00
- name: Checkout
2023-10-31 12:37:26 +00:00
uses: actions/checkout@v4
2020-11-28 10:32:38 +00:00
with:
2020-11-28 10:48:45 +00:00
submodules: true
2020-11-28 10:32:38 +00:00
fetch-depth: 1
2020-11-22 23:41:22 +00:00
- name: Set up QEMU
2023-10-31 12:37:26 +00:00
uses: docker/setup-qemu-action@v3
2020-11-22 23:41:22 +00:00
- name: Set up Docker Buildx
2020-11-17 15:57:03 +00:00
id: buildx
2023-10-31 12:37:26 +00:00
uses: docker/setup-buildx-action@v3
2020-11-17 15:57:03 +00:00
with:
version: latest
install: true
platforms: linux/amd64,linux/arm64
2020-11-22 23:41:22 +00:00
- name: Builder instance name
2020-11-17 15:57:03 +00:00
run: echo ${{ steps.buildx.outputs.name }}
2020-11-22 23:41:22 +00:00
- name: Available platforms
2020-11-17 15:57:03 +00:00
run: echo ${{ steps.buildx.outputs.platforms }}
2020-11-22 23:41:22 +00:00
- name: Cache Docker layers
2023-10-31 12:37:26 +00:00
uses: actions/cache@v3
2020-11-17 15:57:03 +00:00
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
2021-01-30 06:23:09 +00:00
- name: Docker Login
2023-10-31 12:37:26 +00:00
uses: docker/login-action@v3
2021-01-30 06:23:09 +00:00
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
2021-01-30 06:23:09 +00:00
- name: Collect Docker tags
# https://github.com/docker/metadata-action
2021-01-30 06:23:09 +00:00
id: docker_meta
2023-10-31 12:37:26 +00:00
uses: docker/metadata-action@v5
2021-01-30 06:23:09 +00:00
with:
images: archivebox/archivebox,nikisweeting/archivebox
2021-04-05 19:48:30 +00:00
tags: |
# :stable
2021-04-05 19:48:30 +00:00
type=ref,event=branch
# :0.7.3
2021-04-05 19:48:30 +00:00
type=semver,pattern={{version}}
# :0.7
2021-04-05 19:48:30 +00:00
type=semver,pattern={{major}}.{{minor}}
# :sha-463ea54
2023-12-19 06:04:11 +00:00
type=sha
# :latest
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
2020-11-22 23:41:22 +00:00
- name: Build and push
2020-11-17 15:57:03 +00:00
id: docker_build
2023-10-31 12:37:26 +00:00
uses: docker/build-push-action@v5
2020-11-17 15:57:03 +00:00
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
2021-01-30 06:23:09 +00:00
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
2020-11-17 15:57:03 +00:00
cache-from: type=local,src=/tmp/.buildx-cache
2023-12-18 05:18:16 +00:00
cache-to: type=local,dest=/tmp/.buildx-cache-new
platforms: linux/amd64,linux/arm64
2020-11-22 23:41:22 +00:00
- name: Image digest
2020-11-17 15:57:03 +00:00
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Update README
uses: peter-evans/dockerhub-description@v4
with:
2024-02-08 08:47:48 +00:00
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: archivebox/archivebox
2023-12-18 05:18:16 +00:00
# This ugly bit is necessary if you don't want your cache to grow forever
# until it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache