-
Notifications
You must be signed in to change notification settings - Fork 291
96 lines (85 loc) · 2.75 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
93
94
95
96
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@v3
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: x86_64-unknown-linux-musl
override: true
components: rustfmt, clippy
- name: Cache cargo dependencies
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target x86_64-unknown-linux-musl
- uses: actions/upload-artifact@v2
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@v3
- name: Create release tmp folder
run: mkdir -p target/x86_64-unknown-linux-musl/release
- uses: actions/download-artifact@v2
with:
name: realm
path: target/x86_64-unknown-linux-musl/release/realm
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
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@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push images with latest(debian)
uses: docker/build-push-action@v2
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@v2
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