You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.5 KiB
107 lines
3.5 KiB
name: Build and push containers
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["ChangeDetection.io Test"]
|
|
branches: [master]
|
|
tags: '*.*'
|
|
types: [completed]
|
|
|
|
jobs:
|
|
on-success:
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up Python 3.9
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: 3.9
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install flake8 pytest
|
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
|
|
|
|
- name: Create release metadata
|
|
run: |
|
|
# COPY'ed by Dockerfile into changedetectionio/ of the image, then read by the server in store.py
|
|
echo ${{ github.sha }} > changedetectionio/source.txt
|
|
echo ${{ github.ref }} > changedetectionio/tag.txt
|
|
echo Event name: ${{ github.event_name }}
|
|
echo Ref ${{ github.ref }}
|
|
set
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
with:
|
|
image: tonistiigi/binfmt:latest
|
|
platforms: all
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to Docker Hub Container Registry
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
with:
|
|
install: true
|
|
version: latest
|
|
driver-opts: image=moby/buildkit:master
|
|
|
|
- name: Build and push :latest
|
|
id: docker_build
|
|
if: ${{ github.ref == 'master'}}
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: ./
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: |
|
|
${{ secrets.DOCKER_HUB_USERNAME }}/changedetection.io:latest
|
|
ghcr.io/${{ github.repository }}:latest
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
- name: Build and push :tag
|
|
id: docker_build_tag_release
|
|
if: startsWith(github.ref, 'refs/tags/0.')
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: ./
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: |
|
|
${{ secrets.DOCKER_HUB_USERNAME }}/changedetection.io:${{ steps.tagName.outputs.tag }}
|
|
ghcr.io/dgtlmoon/changedetection.io:${{ steps.tagName.outputs.tag }}
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
|
|
- name: Image digest
|
|
run: echo step SHA ${{ steps.vars.outputs.sha_short }} tag ${{steps.vars.outputs.tag}} branch ${{steps.vars.outputs.branch}} digest ${{ steps.docker_build.outputs.digest }}
|
|
|
|
- name: Cache Docker layers
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
|