Catch RequestException in motion events #1917
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker | |
on: | |
schedule: | |
- cron: '31 22 * * 0' | |
push: | |
branches: [main, dev] | |
# Publish semver tags as releases. | |
tags: ['v*.*.*'] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
prebuild: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Should build? | |
run: | | |
if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ]; then | |
echo "The DOCKERHUB_USERNAME secret is missing." | |
exit 1 | |
fi | |
build: | |
needs: [prebuild] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
strategy: | |
matrix: | |
dockerfile: ['multiarch', 'hwaccel', 'qsv'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: matrix image type | |
id: image_type | |
run: | | |
echo "suffix=${{ matrix.dockerfile == 'hwaccel' && '-hw' || matrix.dockerfile == 'qsv' && '-qsv' ||'' }}" >> $GITHUB_OUTPUT | |
echo "platforms=${{ matrix.dockerfile == 'multiarch' && 'linux/amd64,linux/arm64,linux/arm/v7' || 'linux/amd64' }}" >> $GITHUB_OUTPUT | |
echo "arch=${{ matrix.dockerfile == 'multiarch' && 'amd64,armhf,aarch64' || 'amd64' }}" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: ${{ steps.image_type.outputs.platforms }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@master | |
with: | |
platforms: ${{ steps.image_type.outputs.platforms }} | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Log into registry ghcr.io | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ github.repository_owner }}/wyze-bridge | |
ghcr.io/${{ github.repository }} | |
flavor: | | |
latest=auto | |
suffix=${{ steps.image_type.outputs.suffix }},onlatest=true | |
tags: | | |
type=schedule,suffix=${{ steps.image_type.outputs.suffix }} | |
type=semver,pattern={{ version }},suffix=${{ steps.image_type.outputs.suffix }} | |
type=edge,branch=main,enable=${{ github.event_name == 'push' }},suffix=${{ steps.image_type.outputs.suffix }} | |
type=ref,event=branch,enable=${{ contains(github.ref,'dev') }},suffix=${{ steps.image_type.outputs.suffix }} | |
- name: Update Release Version | |
id: version_bump | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
TAG_NAME=${GITHUB_REF##*/v} | |
if [[ $TAG_NAME =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then | |
sed -i "s/^VERSION=.*/VERSION=${TAG_NAME}/" ./app/.env | |
jq --arg VERSION "${TAG_NAME}" '.version = $VERSION' ./app/config.json > updated.json | |
mv updated.json ./app/config.json | |
fi | |
- name: Build and push a Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
context: ./app/ | |
push: ${{ github.event_name != 'pull_request' }} | |
file: ./app/Dockerfile.${{ matrix.dockerfile }} | |
platforms: ${{ steps.image_type.outputs.platforms }} | |
build-args: BUILD=${{ steps.meta.outputs.VERSION }} | |
labels: | | |
${{ steps.meta.outputs.labels }} | |
io.hass.name=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.title'] }} | |
io.hass.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }} | |
io.hass.version=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} | |
io.hass.type=addon | |
io.hass.arch=${{ steps.image_type.outputs.arch }} | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=gha,scope=${{ matrix.dockerfile }} | |
cache-to: type=gha,mode=max,scope=${{ matrix.dockerfile }} | |
provenance: false | |
version_bump: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Update Release Version | |
id: version_bump | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
TAG_NAME=${GITHUB_REF##*/v} | |
if [[ $TAG_NAME =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then | |
sed -i "s/^VERSION=.*/VERSION=${TAG_NAME}/" ./app/.env | |
jq --arg VERSION "${TAG_NAME}" '.version = $VERSION' ./app/config.json > updated.json | |
mv updated.json ./app/config.json | |
echo "tag=${TAG_NAME}" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit and push changes | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
branch: main | |
commit_message: 'Bump Version to v${{ steps.version_bump.outputs.tag }}' | |
file_pattern: 'app/.env app/config.json' |