network-monitor/.gitea/workflows/built-bin.yaml
Ivan Li 0d1dfbf589
Some checks failed
Gitea Actions Demo / build (push) Failing after 8s
Gitea Actions Demo / docker (push) Has been skipped
ci: cache dependencies.
2023-05-21 23:15:45 +08:00

93 lines
2.6 KiB
YAML

name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Restore Dependencies
id: restore-dependencies
uses: https://github.com/actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('~/Cargo.lock') }}
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Rust
uses: https://github.com/actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- id: tag
uses: https://github.com/Maxyme/get-release-or-tag@v2
- name: Build
run: cargo build --release
- name: Cache Dependencies
uses: https://github.com/actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ steps.restore-dependencies.outputs.cache-primarily-key }}
- name: Cache Executable Binary
uses: https://github.com/actions/cache@v3
with:
path: ./target/release/network-monitor
key: ${{ runner.os }}-release-${{ steps.tag.outputs.tag }}
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 }}