-
Notifications
You must be signed in to change notification settings - Fork 293
92 lines (81 loc) · 2.68 KB
/
container-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag of image'
required: true
default: 'test'
push:
tags:
- v*
name: container
jobs:
build:
name: Build Rust project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: ${{ matrix.target }}
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: compile
run: cross build --release --target=x86_64-unknown-linux-musl
- uses: actions/upload-artifact@v4
with:
name: realm
path: target/x86_64-unknown-linux-musl/release/realm
build-and-push:
name: Build and push image
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create release tmp folder
run: mkdir -p target/x86_64-unknown-linux-musl/release
- uses: actions/download-artifact@v4
with:
name: realm
path: target/x86_64-unknown-linux-musl/release/realm
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Echo release version
run: echo ${{ env.RELEASE_VERSION }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push images with latest(debian)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag || env.RELEASE_VERSION }}
- name: Build and push images with alpine
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.alpine
push: true
tags: ghcr.io/${{ github.repository }}:alpine, ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag || env.RELEASE_VERSION }}-alpine