diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index a71bbdb..0000000 --- a/.drone.yml +++ /dev/null @@ -1,49 +0,0 @@ -kind: pipeline -type: docker -name: default - -steps: - - name: build - image: docker - volumes: - - name: socket - path: /var/run/docker.sock - commands: - - DOCKER_BUILDKIT=1 docker build -t automation_rs . - - - name: deploy - image: docker - volumes: - - name: socket - path: /var/run/docker.sock - environment: - MQTT_PASSWORD: - from_secret: MQTT_PASSWORD - HUE_TOKEN: - from_secret: HUE_TOKEN - NTFY_TOPIC: - from_secret: NTFY_TOPIC - RUST_LOG: - from_secret: RUST_LOG - commands: - - docker stop automation_rs || true - - - docker rm automation_rs || true - - # Networks need to be setup to to allow broadcasts: https://www.devwithimagination.com/2020/06/15/homebridge-docker-and-wake-on-lan/ https://github.com/dhutchison/container-images/blob/0c2d7d96bab751fb0a008cc91ba2990724bbd11f/homebridge/configure_docker_networks_for_wol.sh - # Needs to be done for ALL networks, because we can't seem to control which interface gets used to send the broadcast - - docker create -e RUST_LOG=$RUST_LOG -e MQTT_PASSWORD=$MQTT_PASSWORD -e HUE_TOKEN=$HUE_TOKEN -e NTFY_TOPIC=$NTFY_TOPIC --network mqtt --restart unless-stopped --name automation_rs automation_rs - - docker network connect web automation_rs - - docker start automation_rs - - when: - branch: - - master - event: - exclude: - - pull_request - -volumes: - - name: socket - host: - path: /var/run/docker.sock diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..b0e33f4 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,79 @@ +# Based on: https://pastebin.com/99Fq2b2w +name: Build and deploy automation_rs +on: + push: + branches: + - main + - feature/actions + +jobs: + + format: + name: cargo fmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + shared-key: "automation_rs" + - name: Rustfmt check + uses: actions-rust-lang/rustfmt@v1 + + clippy: + name: cargo clippy + runs-on: ubuntu-latest + needs: [format] + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + shared-key: "automation_rs" + - name: Clippy + run: cargo clippy --all-targets --all -- -D warnings + + build: + name: cargo build + runs-on: ubuntu-latest + needs: [clippy] + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + shared-key: "automation_rs" + - name: Build + run: cargo build --release + + # create-docker-container: + # name: docker build + # runs-on: ubuntu-latest + # needs: [build] + # steps: + # - uses: actions/checkout@v4 + # - uses: Swatinem/rust-cache@v2 + # with: + # shared-key: "automation_rs" + # - run: ls -alh + + # create-docker-container: + # runs-on: ubuntu-latest + # container: catthehacker/ubuntu:act-latest + # steps: + # - name: Checkout repository + # uses: https://github.com/actions/checkout@v3 + # + # - name: Set up Docker BuildX + # uses: https://github.com/docker/setup-buildx-action@v3 + # + # - name: Login to registry + # uses: https://github.com/docker/login-action@v3 + # with: + # registry: git.huizinga.dev + # username: ${{ gitea.actor }} + # password: ${{ secrets.REGISTRY_TOKEN }} + # + # - name: Build and push Docker image + # uses: https://github.com/docker/build-push-action@v5 + # with: + # context: . + # push: true + # tags: git.huizinga.dev/dreaded_x/automation_rs:latest diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..f22c82b --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly-2023-11-15" +components = ["rustfmt", "clippy"] +profile = "minimal"