Feature: Deploy Docker container after it is created
All checks were successful
Build and deploy automation_rs / Deploy Docker container (push) Successful in 20s
All checks were successful
Build and deploy automation_rs / Deploy Docker container (push) Successful in 20s
This commit is contained in:
parent
c77064b5b9
commit
c2bbcbcb8a
|
@ -7,63 +7,92 @@ on:
|
||||||
- feature/actions
|
- feature/actions
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
# build:
|
||||||
name: Build
|
# name: Build
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# container: catthehacker/ubuntu:act-latest
|
||||||
|
# steps:
|
||||||
|
# - name: Checkout
|
||||||
|
# uses: actions/checkout@v4
|
||||||
|
#
|
||||||
|
# - name: Setup Rust
|
||||||
|
# uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
# with:
|
||||||
|
# rustflags: ""
|
||||||
|
#
|
||||||
|
# - name: Formatting
|
||||||
|
# uses: actions-rust-lang/rustfmt@v1
|
||||||
|
#
|
||||||
|
# - name: Clippy
|
||||||
|
# run: cargo clippy --all-targets --all -- -D warnings
|
||||||
|
#
|
||||||
|
# - name: Build
|
||||||
|
# run: cargo build --release
|
||||||
|
#
|
||||||
|
# - name: Upload artifact
|
||||||
|
# uses: actions/upload-artifact@v3
|
||||||
|
# with:
|
||||||
|
# name: build
|
||||||
|
# path: target/x86_64-unknown-linux-gnu/release/automation
|
||||||
|
#
|
||||||
|
# container:
|
||||||
|
# name: Create container
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# needs: [build]
|
||||||
|
# container: catthehacker/ubuntu:act-latest
|
||||||
|
# steps:
|
||||||
|
# - name: Checkout
|
||||||
|
# uses: actions/checkout@v4
|
||||||
|
#
|
||||||
|
# - name: Download artifact
|
||||||
|
# uses: actions/download-artifact@v3
|
||||||
|
# with:
|
||||||
|
# name: build
|
||||||
|
#
|
||||||
|
# - name: Set permissions
|
||||||
|
# run: |
|
||||||
|
# chown 65532:65532 ./build/*
|
||||||
|
# chmod 0755 ./build/*
|
||||||
|
#
|
||||||
|
# - 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 & 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
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: Deploy Docker container
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: catthehacker/ubuntu:act-latest
|
container: catthehacker/ubuntu:act-latest
|
||||||
|
# needs: [container]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Stop and remove current container
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Rust
|
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
||||||
with:
|
|
||||||
rustflags: ""
|
|
||||||
|
|
||||||
- name: Formatting
|
|
||||||
uses: actions-rust-lang/rustfmt@v1
|
|
||||||
|
|
||||||
- name: Clippy
|
|
||||||
run: cargo clippy --all-targets --all -- -D warnings
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: cargo build --release
|
|
||||||
|
|
||||||
- name: Upload artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: build
|
|
||||||
path: target/x86_64-unknown-linux-gnu/release/automation
|
|
||||||
|
|
||||||
create-docker-container:
|
|
||||||
name: Create Docker container
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [build]
|
|
||||||
container: catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Download artifact
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: build
|
|
||||||
|
|
||||||
- name: Set permissions
|
|
||||||
run: |
|
run: |
|
||||||
chown 65532:65532 ./build/*
|
docker stop automation_rs || true
|
||||||
chmod 0755 ./build/*
|
docker rm automation_rs || true
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Create container
|
||||||
uses: https://github.com/docker/login-action@v3
|
run: |
|
||||||
with:
|
docker create \
|
||||||
registry: git.huizinga.dev
|
--pull always \
|
||||||
username: ${{ gitea.actor }}
|
--restart unless-stopped \
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
--name automation_rs \
|
||||||
|
-e RUST_LOG=${{ secrets.RUST_LOG }} \
|
||||||
|
-e MQTT_PASSWORD=${{ secrets.MQTT_PASSWORD }} \
|
||||||
|
-e HUE_TOKEN=${{ secrets.HUE_TOKEN }} \
|
||||||
|
-e NTFY_TOPIC=${{ secrets.NTFY_TOPIC }} \
|
||||||
|
git.huizinga.dev/dreaded_x/automation_rs:latest
|
||||||
|
|
||||||
- name: Build & Push Docker Image
|
docker network connect mqtt automation_rs
|
||||||
uses: https://github.com/docker/build-push-action@v5
|
docker network connect web automation_rs
|
||||||
with:
|
|
||||||
context: .
|
- name: Start container
|
||||||
push: true
|
run: docker start automation_rs
|
||||||
tags: git.huizinga.dev/dreaded_x/automation_rs:latest
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user