From a890ec8b494ce031890603addd16cbe21bb7deec Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Fri, 13 Nov 2020 09:10:34 +0100 Subject: [PATCH] add sleep + CI update --- .github/workflows/build.yaml | 31 ++++++++++++++ .github/workflows/dockerimage.yml | 69 ------------------------------- .github/workflows/release.yml | 62 +++++++++++++++++++++++++++ lirc_watcher.py | 4 +- 4 files changed, 96 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/build.yaml delete mode 100644 .github/workflows/dockerimage.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..72f2b5b --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,31 @@ +name: docker build + +on: + push: + paths-ignore: + - 'README.md' + branches: + - master + pull_request: + branches: + - '*' + schedule: + - cron: '0 7 1 * *' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build + uses: docker/build-push-action@v2 diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml deleted file mode 100644 index 3c4768e..0000000 --- a/.github/workflows/dockerimage.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: docker build - -on: - push: - paths-ignore: - - "README.md" - branches: - - master - pull_request: - branches: - - master - release: - types: - - created - schedule: - - cron: "0 0 1 * *" - -jobs: - build: - if: "!contains(github.event.commits[0].message, '[skip ci]')" - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Prepare - id: prepare - run: | - HEAD_TAG=$(git tag --points-at HEAD) - PLATFORMS=linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 - VERSION=latest - - if [[ $HEAD_TAG =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - VERSION=${HEAD_TAG//v} - fi - - echo ::set-output name=version::${VERSION} - echo ::set-output name=docker_image::${GITHUB_REPOSITORY//docker-} - echo ::set-output name=platforms::${PLATFORMS} - - - name: Build on pull request - if: success() && github.event_name == 'pull_request' - run: | - docker build . - - - name: Set up Docker Buildx - if: success() && github.event_name != 'pull_request' - uses: crazy-max/ghaction-docker-buildx@v3 - with: - buildx-version: latest - qemu-version: latest - - - name: Docker Login - if: success() && github.event_name != 'pull_request' - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: | - echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin - - - name: Build & Push - if: success() && github.event_name != 'pull_request' - run: | - docker buildx build \ - --platform ${{ steps.prepare.outputs.platforms }} \ - --tag ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} \ - --file ./Dockerfile \ - --push . - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7634d4b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: release + +on: + push: + tags: + - "v*" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + id: prepare + run: | + git fetch --prune --unshallow --tags + + VERSION=$(git tag --points-at HEAD) + VERSION=${VERSION//v} + IMAGE_NAME=${GITHUB_REPOSITORY#*/} + IMAGE_NAME="${{ secrets.DOCKERHUB_USER }}/${IMAGE_NAME//docker-}" + IMAGE_TAGS="${IMAGE_NAME}:latest,${IMAGE_NAME}:${VERSION}" + + echo "## :bookmark_tabs: Changes" >>"CHANGELOG.md" + git log --pretty=format:"- %s %H%n" $(git describe --abbrev=0 --tags $(git describe --tags --abbrev=0)^)...$(git describe --tags --abbrev=0) >>"CHANGELOG.md" + + echo ::set-output name=image_tags::${IMAGE_TAGS} + echo ::set-output name=version::${VERSION} + echo ::set-output name=changelog::${CHANGELOG} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v2 + with: + push: true + tags: ${{ steps.prepare.outputs.image_tags }} + + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ steps.prepare.outputs.version }} + body_path: CHANGELOG.md + draft: false + prerelease: false \ No newline at end of file diff --git a/lirc_watcher.py b/lirc_watcher.py index 77195f5..8c2920c 100644 --- a/lirc_watcher.py +++ b/lirc_watcher.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -import socket import os import paho.mqtt.client as paho from threading import Timer @@ -116,6 +115,9 @@ def send_code(priority_data=None): t = Timer(READ_TIMEOUT, send_code) t.start() + time.sleep(0.01) + + except KeyboardInterrupt: mqtt.disconnect() mqtt.loop_stop()