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
|
2023-05-22 10:33:50 +08:00
|
|
|
container:
|
2023-05-22 10:37:40 +08:00
|
|
|
image: catthehacker/ubuntu:act-latest
|
2023-05-22 10:30:57 +08:00
|
|
|
|
|
|
|
env:
|
|
|
|
REGISTRY: git.ivanli.cc
|
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
|
2023-05-21 14:16:03 +08:00
|
|
|
steps:
|
2023-05-21 23:19:39 +08:00
|
|
|
- name: Check out repository code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Get Dependencies Index Hash
|
2023-05-21 23:47:28 +08:00
|
|
|
uses: https://github.com/KEINOS/gh-action-hash-for-cache@main
|
2023-05-21 23:19:39 +08:00
|
|
|
id: hash-dependencies-index
|
|
|
|
with:
|
2023-05-21 23:47:28 +08:00
|
|
|
path: '**/Cargo.lock'
|
2023-05-21 23:19:39 +08:00
|
|
|
|
2023-05-21 17:12:29 +08:00
|
|
|
- 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/
|
2023-05-21 23:19:39 +08:00
|
|
|
key: ${{ runner.os }}-cargo-${{ steps.hash-dependencies-index.outputs.hash }}
|
2023-05-21 16:21:07 +08:00
|
|
|
|
|
|
|
- name: Install Rust
|
2023-05-21 16:27:41 +08:00
|
|
|
uses: https://github.com/actions-rs/toolchain@v1
|
2023-05-21 16:21:07 +08:00
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
|
2023-05-21 23:56:17 +08:00
|
|
|
- name: Get Commit Tag
|
|
|
|
id: tag
|
2023-05-21 23:27:40 +08:00
|
|
|
uses: https://github.com/Maxyme/get-release-or-tag@v2
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: cargo build --release
|
2023-05-22 10:48:48 +08:00
|
|
|
|
2023-05-22 10:55:57 +08:00
|
|
|
- run: echo "secrets.GITHUB_TOKEN ${{ secrets.GITHUB_TOKEN }}, secrets.GITEA_TOKEN ${{ secrets.GITEA_TOKEN }}"
|
2023-05-21 16:56:55 +08:00
|
|
|
|
2023-05-21 16:21:07 +08:00
|
|
|
- name: Log in to the Container registry
|
2023-05-21 23:43:44 +08:00
|
|
|
uses: https://github.com/docker/login-action@v2
|
2023-05-21 16:21:07 +08:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ gitea.actor }}
|
2023-05-22 10:48:48 +08:00
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2023-05-21 16:21:07 +08:00
|
|
|
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
|
|
id: meta
|
2023-05-21 23:43:44 +08:00
|
|
|
uses: https://github.com/docker/metadata-action@v4
|
2023-05-21 16:21:07 +08:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
|
|
|
|
- name: Build and push Docker image
|
2023-05-22 10:55:57 +08:00
|
|
|
uses: docker/build-push-action@master
|
2023-05-22 00:21:35 +08:00
|
|
|
env:
|
|
|
|
ACTIONS_RUNTIME_TOKEN: ''
|
2023-05-21 16:21:07 +08:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|