2020-11-28 10:44:37 +00:00
|
|
|
name: Docker
|
2020-11-17 15:57:03 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2020-12-03 16:33:10 +00:00
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- created
|
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:
|
2020-11-28 10:32:38 +00:00
|
|
|
test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
with:
|
2020-11-28 10:48:45 +00:00
|
|
|
submodules: true
|
2020-11-28 10:32:38 +00:00
|
|
|
fetch-depth: 1
|
|
|
|
|
|
|
|
# TODO: as of 2020-11 this helper layer broke, upgrade and re-enable this once it's usable again
|
|
|
|
# - uses: satackey/action-docker-layer-caching@v0.0.8
|
|
|
|
|
|
|
|
- name: Build image
|
|
|
|
run: |
|
|
|
|
docker build . -t "$DOCKER_IMAGE"
|
|
|
|
|
|
|
|
- name: Init data dir
|
|
|
|
run: |
|
|
|
|
mkdir data
|
|
|
|
docker run -v "$PWD"/data:/data "$DOCKER_IMAGE" init
|
|
|
|
|
|
|
|
- name: Run test server
|
|
|
|
run: |
|
|
|
|
sudo bash -c 'echo "127.0.0.1 www.test-nginx-1.local www.test-nginx-2.local" >> /etc/hosts'
|
|
|
|
docker run --name www-nginx -p 80:80 -d nginx
|
|
|
|
|
|
|
|
- name: Add link
|
|
|
|
run: |
|
|
|
|
docker run -v "$PWD"/data:/data --network host "$DOCKER_IMAGE" add http://www.test-nginx-1.local
|
|
|
|
|
|
|
|
- name: Add stdin link
|
|
|
|
run: |
|
|
|
|
echo "http://www.test-nginx-2.local" | docker run -i --network host -v "$PWD"/data:/data "$DOCKER_IMAGE" add
|
|
|
|
|
|
|
|
- name: List links
|
|
|
|
run: |
|
|
|
|
docker run -v "$PWD"/data:/data "$DOCKER_IMAGE" list | grep -q "www.test-nginx-1.local" || { echo "The site 1 isn't in the list"; exit 1; }
|
|
|
|
docker run -v "$PWD"/data:/data "$DOCKER_IMAGE" list | grep -q "www.test-nginx-2.local" || { echo "The site 2 isn't in the list"; exit 1; }
|
|
|
|
|
|
|
|
- name: Start docker-compose stack
|
|
|
|
run: |
|
|
|
|
docker-compose run archivebox init
|
|
|
|
docker-compose up -d
|
|
|
|
sleep 5
|
|
|
|
curl --silent --location 'http://127.0.0.1:8000' | grep 'ArchiveBox'
|
|
|
|
curl --silent --location 'http://127.0.0.1:8000/static/admin/js/jquery.init.js' | grep 'window.django'
|
|
|
|
|
|
|
|
- name: Check added urls show up in index
|
|
|
|
run: |
|
|
|
|
docker-compose run archivebox add 'http://example.com/#test_docker' --index-only
|
|
|
|
curl --silent --location 'http://127.0.0.1:8000' | grep 'http://example.com/#test_docker'
|
|
|
|
docker-compose down || true
|
|
|
|
|
2020-11-17 15:57:03 +00:00
|
|
|
buildx:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2020-11-22 23:41:22 +00:00
|
|
|
- name: Docker Login
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
2020-11-22 23:01:39 +00:00
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2020-11-28 10:32:38 +00:00
|
|
|
|
2020-11-22 23:41:22 +00:00
|
|
|
- name: Checkout
|
2020-11-17 15:57:03 +00:00
|
|
|
uses: actions/checkout@v2
|
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
|
2020-11-17 15:57:03 +00:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-11-28 10:32:38 +00:00
|
|
|
|
2020-11-22 23:41:22 +00:00
|
|
|
- name: Set up Docker Buildx
|
2020-11-17 15:57:03 +00:00
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
with:
|
|
|
|
version: latest
|
|
|
|
install: true
|
2020-11-28 10:32:38 +00:00
|
|
|
|
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-28 10:32:38 +00:00
|
|
|
|
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-28 10:32:38 +00:00
|
|
|
|
2020-11-22 23:41:22 +00:00
|
|
|
- name: Cache Docker layers
|
2020-11-17 15:57:03 +00:00
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
2020-11-28 10:32:38 +00:00
|
|
|
|
2020-11-22 23:41:22 +00:00
|
|
|
- name: Build and push
|
2020-11-17 15:57:03 +00:00
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: ./
|
|
|
|
file: ./Dockerfile
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
push: true
|
|
|
|
tags: |
|
2020-11-22 23:01:39 +00:00
|
|
|
${{ secrets.DOCKER_USERNAME }}/archivebox:latest
|
|
|
|
${{ secrets.DOCKER_USERNAME }}/archivebox:${{ github.sha }}
|
2020-11-23 07:00:02 +00:00
|
|
|
archivebox/archivebox:latest
|
|
|
|
archivebox/archivebox:${{ github.sha }}
|
2020-11-17 15:57:03 +00:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
2020-11-24 04:12:27 +00:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
2020-11-28 10:32:38 +00:00
|
|
|
|
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 }}
|