network-monitor/.gitea/workflows/built-bin.yaml

82 lines
2.2 KiB
YAML
Raw Normal View History

2023-05-21 14:16:03 +08:00
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions
2023-05-21 16:21:07 +08:00
on: [push, pull_request]
2023-05-21 14:16:03 +08:00
jobs:
2023-05-21 16:21:07 +08:00
build:
2023-05-21 14:16:03 +08:00
runs-on: ubuntu-latest
steps:
2023-05-21 16:21:07 +08:00
2023-05-21 14:16:03 +08:00
- name: Check out repository code
uses: actions/checkout@v3
2023-05-21 16:21:07 +08:00
- name: Install Rust
uses: https://github.com/actions-rs/toolchain@v1
2023-05-21 16:21:07 +08:00
with:
toolchain: stable
override: true
2023-05-21 16:46:22 +08:00
- id: tag
uses: https://github.com/Maxyme/get-release-or-tag@v2
2023-05-21 16:21:07 +08:00
- name: Build
run: cargo build --release
2023-05-21 16:56:55 +08:00
- name: Cache Dependencies
uses: https://github.com/actions/cache@v3
with:
2023-05-21 17:02:08 +08:00
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
2023-05-21 17:08:19 +08:00
key: ${{ runner.os }}-cargo
2023-05-21 16:56:55 +08:00
2023-05-21 16:21:07 +08:00
- name: Cache Executable Binary
2023-05-21 16:47:38 +08:00
uses: https://github.com/actions/cache@v3
2023-05-21 16:21:07 +08:00
with:
path: ./target/release/network-monitor
2023-05-21 16:56:55 +08:00
key: ${{ runner.os }}-release-${{ steps.tag.outputs.tag }}
2023-05-21 16:21:07 +08:00
docker:
runs-on: ubuntu-latest
needs: build
env:
REGISTRY: gitea.ivanli.cc
IMAGE_NAME: ${{ github.repository }}
steps:
- id: restore-executable-binary
name: Cache Executable Binaries
uses: actions/cache@v3
with:
path: ./network-monitor
key: ${{ runner.os }}-release-${{ steps.commit.outputs.short}}
- if: ${{ steps.restore-executable-binary.outputs.cache-hit != 'true' }}
name: List the state of node modules
run: echo "missing program"
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
registry: ${{ env.REGISTRY }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}