2020-12-06 09:26:44 -05:00
|
|
|
name: Build Docker image
|
2020-11-17 10:57:03 -05:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2020-12-03 11:33:10 -05:00
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- created
|
2020-11-17 10:57:03 -05:00
|
|
|
|
2020-11-28 05:32:38 -05:00
|
|
|
env:
|
|
|
|
DOCKER_IMAGE: archivebox-ci
|
|
|
|
|
|
|
|
|
2020-11-17 10:57:03 -05:00
|
|
|
jobs:
|
|
|
|
buildx:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2020-11-22 18:41:22 -05:00
|
|
|
- name: Docker Login
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
2020-11-22 18:01:39 -05:00
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2020-11-28 05:32:38 -05:00
|
|
|
|
2020-11-22 18:41:22 -05:00
|
|
|
- name: Checkout
|
2020-11-17 10:57:03 -05:00
|
|
|
uses: actions/checkout@v2
|
2020-11-28 05:32:38 -05:00
|
|
|
with:
|
2020-11-28 05:48:45 -05:00
|
|
|
submodules: true
|
2020-11-28 05:32:38 -05:00
|
|
|
fetch-depth: 1
|
|
|
|
|
2020-11-22 18:41:22 -05:00
|
|
|
- name: Set up QEMU
|
2020-11-17 10:57:03 -05:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-11-28 05:32:38 -05:00
|
|
|
|
2020-11-22 18:41:22 -05:00
|
|
|
- name: Set up Docker Buildx
|
2020-11-17 10:57:03 -05:00
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
with:
|
|
|
|
version: latest
|
|
|
|
install: true
|
2020-11-28 05:32:38 -05:00
|
|
|
|
2020-11-22 18:41:22 -05:00
|
|
|
- name: Builder instance name
|
2020-11-17 10:57:03 -05:00
|
|
|
run: echo ${{ steps.buildx.outputs.name }}
|
2020-11-28 05:32:38 -05:00
|
|
|
|
2020-11-22 18:41:22 -05:00
|
|
|
- name: Available platforms
|
2020-11-17 10:57:03 -05:00
|
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
2020-11-28 05:32:38 -05:00
|
|
|
|
2020-11-22 18:41:22 -05:00
|
|
|
- name: Cache Docker layers
|
2020-11-17 10:57:03 -05:00
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
2020-11-28 05:32:38 -05:00
|
|
|
|
2021-01-13 09:07:12 -05:00
|
|
|
- name: Prepare tags to publish
|
|
|
|
id: prep
|
2021-01-10 17:08:00 -05:00
|
|
|
run: |
|
2021-01-13 09:07:12 -05:00
|
|
|
# Always publish to latest.
|
|
|
|
TAGS="${{ secrets.DOCKER_USERNAME }}/archivebox:latest,archivebox/archivebox:latest"
|
2021-01-10 19:07:50 -05:00
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
2021-01-13 09:07:12 -05:00
|
|
|
VERSION="${GITHUB_REF#refs/tags/}"
|
|
|
|
MINOR=${VERSION%.*}
|
|
|
|
MAJOR=${MINOR%.*}
|
|
|
|
TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/archivebox:$VERSION,archivebox/archivebox:$VERSION"
|
|
|
|
TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/archivebox:$MINOR,archivebox/archivebox:$MINOR"
|
|
|
|
TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/archivebox:$MAJOR,archivebox/archivebox:$MAJOR"
|
2021-01-10 17:08:00 -05:00
|
|
|
else
|
2021-01-13 09:07:12 -05:00
|
|
|
VERSION=$GITHUB_SHA
|
|
|
|
TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/archivebox:$VERSION,archivebox/archivebox:$VERSION"
|
2021-01-10 17:08:00 -05:00
|
|
|
fi
|
2021-01-13 09:07:12 -05:00
|
|
|
|
|
|
|
echo ::set-output name=tags::${TAGS}
|
2021-01-10 17:08:00 -05:00
|
|
|
env:
|
|
|
|
GITHUB_REF: ${{ github.ref }}
|
|
|
|
GITHUB_SHA: ${{ github.sha }}
|
|
|
|
|
2020-11-22 18:41:22 -05:00
|
|
|
- name: Build and push
|
2020-11-17 10:57:03 -05:00
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: ./
|
|
|
|
file: ./Dockerfile
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
push: true
|
2021-01-13 09:07:12 -05:00
|
|
|
tags: ${{ steps.prep.outputs.tags }}
|
2020-11-17 10:57:03 -05:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
2020-11-23 23:12:27 -05:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
2021-01-10 17:08:00 -05:00
|
|
|
|
2020-11-22 18:41:22 -05:00
|
|
|
- name: Image digest
|
2020-11-17 10:57:03 -05:00
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|