build: fix gitea actions

This commit is contained in:
Ondrej Vlach 2023-12-03 19:22:18 +01:00
parent 503c674d5e
commit 0a21cc140a
Signed by: ovlach
GPG Key ID: 4FF1A23B4914DE70
4 changed files with 34 additions and 23 deletions

View File

@ -6,8 +6,17 @@ on:
- master - master
jobs: jobs:
tests: tests:
uses: ./.gitea/workflows/test.yaml # use the callable tests job to run tests name: tests
secrets: inherit runs-on: ubuntu-latest
steps:
- uses: https://github.com/actions/checkout.git@v4
- name: tests
uses: nanobyte-public/rust-action@master
with:
args: |
CARGO_HOME=./.cache cargo-nan \"Bearer ${{secrets.deployment_package}}\" cargo clippy -- -Dwarnings && \
CARGO_HOME=./.cache cargo-nan \"Bearer ${{secrets.deployment_package}}\" cargo clippy --tests -- -Dwarnings && \
CARGO_HOME=./.cache cargo-nan \"Bearer ${{secrets.deployment_package}}\" cargo test
deploy: deploy:
name: deploy name: deploy
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -27,5 +36,5 @@ jobs:
run: echo "::set-output name=short_hash::$(git rev-parse --short HEAD)" run: echo "::set-output name=short_hash::$(git rev-parse --short HEAD)"
- name: Build and push docker - name: Build and push docker
run: | run: |
docker build . -t git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_backend:${{steps.git.outputs.short_hash}} --build-arg GITEA_TOKEN="Bearer ${{secrets.DEPLOYMENT_PACKAGE}}" && \ docker build . -t git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_frontend:${{steps.git.outputs.short_hash}} --build-arg GITEA_TOKEN="Bearer ${{secrets.DEPLOYMENT_PACKAGE}}" && \
docker push git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_backend:${{steps.git.outputs.short_hash}} docker push git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_frontend:${{steps.git.outputs.short_hash}}

View File

@ -1,11 +1,6 @@
name: test name: test
run-name: test run-name: test
on: on:
workflow_call:
secrets:
DEPLOYMENT_PACKAGE:
description: 'needed for checkout depenediencies'
required: true
push: push:
branches: branches:
- '*' - '*'
@ -29,7 +24,7 @@ jobs:
restore-keys: ${{github.repository}}-cache-cargo-clippy-v4 restore-keys: ${{github.repository}}-cache-cargo-clippy-v4
- uses: nanobyte-public/rust-action@master - uses: nanobyte-public/rust-action@master
with: with:
args: CARGO_HOME=./.cache cargo-nan \"Bearer ${{secrets.DEPLOYMENT_PACKAGE}}\" cargo clippy -- -Dwarnings args: CARGO_HOME=./.cache cargo-nan \"Bearer ${{secrets.deployment_package}}\" cargo clippy -- -Dwarnings
- uses: https://gitea.com/wolfogre/cache/save@v3 - uses: https://gitea.com/wolfogre/cache/save@v3
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
with: with:
@ -57,7 +52,7 @@ jobs:
- uses: nanobyte-public/rust-action@master - uses: nanobyte-public/rust-action@master
with: with:
args: | args: |
CARGO_HOME=./.cache cargo-nan \"Bearer ${{secrets.DEPLOYMENT_PACKAGE}}\" cargo test CARGO_HOME=./.cache cargo-nan \"Bearer ${{secrets.deployment_package}}\" cargo test
- uses: https://gitea.com/wolfogre/cache/save@v3 - uses: https://gitea.com/wolfogre/cache/save@v3
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
with: with:

View File

@ -1,14 +1,20 @@
FROM rust:1.74.0-slim-bookworm AS builder FROM git.nanobyte.cz/nanobyte/nano-rust:1.74.4e44cba AS builder
COPY . /app ARG PACKAGE_NAME="ovlach_frontend"
WORKDIR /app ARG GITEA_TOKEN
RUN mkdir ~/.ssh
RUN apt-get update && apt-get install -y ssh && rm -rf /var/cache/apt*
RUN ssh-keyscan gitlab.nanobyte.cz >> /root/.ssh/known_hosts
RUN cargo build --release
FROM rust:1.74.0-slim-bookworm as runner COPY . /data/
RUN mkdir /app RUN cd /data && cargo-nan "${GITEA_TOKEN}" cargo build --release
COPY --from=builder /app/target/release/ovlach_frontend /app
COPY ./templates /app/templates FROM git.nanobyte.cz/nanobyte/nano-rust:1.74.4e44cba
ENTRYPOINT ["/app/ovlach_frontend"] ARG PACKAGE_NAME="ovlach_frontend"
ARG GITEA_TOKEN
COPY --from=builder /data/target/release/${PACKAGE_NAME} /bin
RUN mkdir /rund
COPY Rocket.toml /rund
COPY templates/* /rund/templates/
WORKDIR /rund
EXPOSE 8000
ENV ROCKET_ADDRESS=0.0.0.0
ENV PACKAGE_NAME=${PACKAGE_NAME}
ENTRYPOINT $PACKAGE_NAME

View File

@ -9,3 +9,4 @@ cv_backend_path = "http://localhost:8002"
contact_service = "http://localhost:8004" contact_service = "http://localhost:8004"
pdf_service = "http://localhost:8003" pdf_service = "http://localhost:8003"
default_person_name = "ovlach" default_person_name = "ovlach"
port = 8000