Improved workflow
This commit is contained in:
parent
32aa981e31
commit
526c82096c
|
@ -1,5 +1,5 @@
|
||||||
# Based on: https://pastebin.com/99Fq2b2w
|
# Based on: https://pastebin.com/99Fq2b2w
|
||||||
name: Build and deploy automation_rs
|
name: Build and deploy
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
@ -7,49 +7,8 @@ on:
|
||||||
- feature/**
|
- feature/**
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
|
||||||
name: Run pre-commit checks
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup go
|
|
||||||
uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: ">=1.20.1"
|
|
||||||
- name: Calculate cache hash
|
|
||||||
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
|
|
||||||
id: hash-go
|
|
||||||
with:
|
|
||||||
patterns: |
|
|
||||||
.pre-commit-config.yaml
|
|
||||||
- name: Setup cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pre-commit
|
|
||||||
key: pre-commit-3|${{ steps.hash-go.outputs.hash }}
|
|
||||||
|
|
||||||
- name: Install pre-commit
|
|
||||||
run: python -m pip install pre-commit
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Setup Rust
|
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
||||||
with:
|
|
||||||
rustflags: ""
|
|
||||||
|
|
||||||
- name: Set rustup default
|
|
||||||
run: rustup default stable
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Run pre-commit
|
|
||||||
run: pre-commit run --show-diff-on-failure --color=always --all-files
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build automation_rs
|
name: Build application
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: catthehacker/ubuntu:act-latest
|
container: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -71,9 +30,9 @@ jobs:
|
||||||
path: target/x86_64-unknown-linux-gnu/release/automation
|
path: target/x86_64-unknown-linux-gnu/release/automation
|
||||||
|
|
||||||
container:
|
container:
|
||||||
name: Build Docker image
|
name: Build container
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build, checks]
|
needs: [build]
|
||||||
container: catthehacker/ubuntu:act-latest
|
container: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
@ -89,6 +48,17 @@ jobs:
|
||||||
chown 65532:65532 ./build/*
|
chown 65532:65532 ./build/*
|
||||||
chmod 0755 ./build/*
|
chmod 0755 ./build/*
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: https://github.com/docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: git.huizinga.dev/dreaded_x/automation_rs
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Login to registry
|
||||||
uses: https://github.com/docker/login-action@v3
|
uses: https://github.com/docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
@ -100,12 +70,12 @@ jobs:
|
||||||
uses: https://github.com/docker/build-push-action@v5
|
uses: https://github.com/docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ gitea.ref == 'refs/heads/master' }}
|
push: true
|
||||||
# TODO: Automatically add the correct tags here
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
tags: git.huizinga.dev/dreaded_x/automation_rs:latest
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy Docker container
|
name: Deploy container
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: catthehacker/ubuntu:act-latest
|
container: catthehacker/ubuntu:act-latest
|
||||||
needs: [container]
|
needs: [container]
|
||||||
|
@ -127,7 +97,7 @@ jobs:
|
||||||
-e MQTT_PASSWORD=${{ secrets.MQTT_PASSWORD }} \
|
-e MQTT_PASSWORD=${{ secrets.MQTT_PASSWORD }} \
|
||||||
-e HUE_TOKEN=${{ secrets.HUE_TOKEN }} \
|
-e HUE_TOKEN=${{ secrets.HUE_TOKEN }} \
|
||||||
-e NTFY_TOPIC=${{ secrets.NTFY_TOPIC }} \
|
-e NTFY_TOPIC=${{ secrets.NTFY_TOPIC }} \
|
||||||
git.huizinga.dev/dreaded_x/automation_rs:latest
|
git.huizinga.dev/dreaded_x/automation_rs:master
|
||||||
|
|
||||||
docker network connect web automation_rs
|
docker network connect web automation_rs
|
||||||
|
|
||||||
|
|
17
.gitea/workflows/checks.yml
Normal file
17
.gitea/workflows/checks.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
name: Check
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: "**"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Run checks
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: git.huizinga.dev/dreaded_x/pre-commit:master
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Run pre-commit
|
||||||
|
run: SKIP=sqlx-prepare pre-commit run --show-diff-on-failure --color=always --all-files
|
||||||
|
shell: bash
|
Loading…
Reference in New Issue
Block a user