From 106c3269a63b448499a5d9ed733d044a4ad2ba44 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 5 Oct 2021 10:16:23 +0200 Subject: [PATCH] Separate workflows --- .../workflows/dockerhub-container-tagged.yml | 18 +---- .github/workflows/dockerhub-container.yml | 77 +++++++++++++++++++ 2 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/dockerhub-container.yml diff --git a/.github/workflows/dockerhub-container-tagged.yml b/.github/workflows/dockerhub-container-tagged.yml index 7ea1dfb1..d54f8c11 100644 --- a/.github/workflows/dockerhub-container-tagged.yml +++ b/.github/workflows/dockerhub-container-tagged.yml @@ -9,7 +9,6 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - name: Set up Python 3.9 uses: actions/setup-python@v2 @@ -23,7 +22,6 @@ jobs: # tagRegex: "foobar-(.*)" # Optional. Returns specified group text as tag name. Full tag string is returned if regex is not defined. # tagRegexGroup: 1 # Optional. Default is 1. - - name: Install dependencies run: | python -m pip install --upgrade pip @@ -31,24 +29,12 @@ jobs: 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: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - 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 - - name: Test with pytest - run: | - # Each test is totally isolated and performs its own cleanup/reset - cd changedetectionio; ./run_all_tests.sh - - name: Set up QEMU uses: docker/setup-qemu-action@v1 with: @@ -69,7 +55,9 @@ jobs: driver-opts: image=moby/buildkit:master - name: tag - run : echo ${{ github.event.release.tag_name }} + run : | + set + echo ${{ github.event.release.tag_name }} - name: Build and push tagged version id: docker_build diff --git a/.github/workflows/dockerhub-container.yml b/.github/workflows/dockerhub-container.yml new file mode 100644 index 00000000..8169b012 --- /dev/null +++ b/.github/workflows/dockerhub-container.yml @@ -0,0 +1,77 @@ +name: Test, build and push to Docker Hub (master/latest) + +on: + workflow_run: + workflows: ["ChangeDetection.io Test"] + 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 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all + + - name: Login to Docker Hub + 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 + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + push: true + tags: | + ${{ secrets.DOCKER_HUB_USERNAME }}/changedetection.io + 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 }} + +# failed: Cache service responded with 503 +# - name: Cache Docker layers +# uses: actions/cache@v2 +# with: +# path: /tmp/.buildx-cache +# key: ${{ runner.os }}-buildx-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-buildx- + +