-
Notifications
You must be signed in to change notification settings - Fork 115
121 lines (99 loc) · 3.13 KB
/
Copy pathdocker-image.yml
File metadata and controls
121 lines (99 loc) · 3.13 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Docker Image CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: restsend/rustpbx
jobs:
build-amd64:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Build AMD64 Binaries
run: |
cross build --release --target x86_64-unknown-linux-gnu --features cross --bin rustpbx --bin sipflow
mkdir -p bin/amd64
cp target/x86_64-unknown-linux-gnu/release/rustpbx bin/amd64/
cp target/x86_64-unknown-linux-gnu/release/sipflow bin/amd64/
- name: Upload AMD64 Binaries
uses: actions/upload-artifact@v4
with:
name: bin-amd64
path: bin/amd64
if-no-files-found: error
build-arm64:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Build ARM64 Binaries
run: |
cross build --release --target aarch64-unknown-linux-gnu --features cross --bin rustpbx --bin sipflow
mkdir -p bin/arm64
cp target/aarch64-unknown-linux-gnu/release/rustpbx bin/arm64/
cp target/aarch64-unknown-linux-gnu/release/sipflow bin/arm64/
- name: Upload ARM64 Binaries
uses: actions/upload-artifact@v4
with:
name: bin-arm64
path: bin/arm64
if-no-files-found: error
docker-image:
runs-on: ubuntu-latest
needs:
- build-amd64
- build-arm64
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Download AMD64 Binaries
uses: actions/download-artifact@v4
with:
name: bin-amd64
path: bin/amd64
- name: Download ARM64 Binaries
uses: actions/download-artifact@v4
with:
name: bin-arm64
path: bin/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container registry
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && contains(github.event.head_commit.message, '[latest]')) }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
sbom: false