forked from ideal-world/spacegate
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (118 loc) · 4.72 KB
/
admin-server-cicd.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: ADMIN SERVER CICD
on:
push:
paths:
- 'binary/admin-server/**'
- 'crates/config/**'
- 'Cargo.toml'
- '.github/workflows/admin-server-cicd.yml'
env:
ARTIFACT_DIR: release-artifacts
FRONTEND_ARTIFACT_NAME: frontend-artifact
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Init rust envrionment
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache rust
uses: Swatinem/rust-cache@v2
- name: Check format
run: cargo fmt -p spacegate-config -- --check
- name: Check clippy
run: cargo clippy -p spacegate-admin-server --all-features
- name: Run rust test
run: cargo test -p spacegate-admin-server --all-features
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
docker-images: false
swap-storage: false
android: true
dotnet: true
haskell: true
large-packages: true
push-docker:
if: startsWith(github.ref, 'refs/tags/') != true
needs: [check]
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Cache rust
uses: Swatinem/rust-cache@v2
- name: Build rust
run: cargo build --release -p spacegate-admin-server
- name: Copy artifact to workspace
run: cp ./target/release/spacegate-admin-server resource/docker/spacegate-admin-server/
- name: Get front run id
run: |
run_id=$(curl https://api.github.com/repos/ideal-world/spacegate-admin-fe/actions/workflows/cicd.yml/runs\?status\=success |jq '.workflow_runs[0].id' )
echo "FRONTEND_RUN_ID=${run_id}" >> $GITHUB_ENV
- name: Download front artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.FRONTEND_ARTIFACT_NAME }}
repository: ideal-world/spacegate-admin-fe
path: resource/docker/spacegate-admin-server/
run-id: ${{ env.FRONTEND_RUN_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract front artifact
run: cd resource/docker/spacegate-admin-server && tar -xzvf ${{ env.FRONTEND_ARTIFACT_NAME }}.tar.gz
- name: Build and push Docker image to dockerhub
uses: mr-smithers-excellent/docker-build-push@v5
with:
directory: resource/docker/spacegate-admin-server
dockerfile: resource/docker/spacegate-admin-server/Dockerfile
registry: docker.io
image: ecfront/spacegate-admin-server
tags: latest
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
release-docker:
if: startsWith(github.ref, 'refs/tags/')
needs: [check]
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Cache rust
uses: Swatinem/rust-cache@v2
- name: Build rust
run: cargo build --release -p spacegate-admin-server
- name: Copy artifact to workspace
run: cp ./target/release/spacegate-admin-server resource/docker/spacegate-admin-server
- name: Get front run id
run: |
run_id=$(curl https://api.github.com/repos/ideal-world/spacegate-admin-fe/actions/workflows/cicd.yml/runs\?status\=success |jq '.workflow_runs[0].id' )
echo "FRONTEND_RUN_ID=${run_id}" >> $GITHUB_ENV
- name: Download front artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.FRONTEND_ARTIFACT_NAME }}
repository: ideal-world/spacegate-admin-fe
path: resource/docker/spacegate-admin-server
run-id: ${{ env.FRONTEND_RUN_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract front artifact
run: cd resource/docker/spacegate-admin-server/ && tar -xzvf ${{ env.FRONTEND_ARTIFACT_NAME }}.tar.gz
- name: Build and push Docker image to dockerhub
uses: mr-smithers-excellent/docker-build-push@v5
with:
directory: resource/docker/spacegate-admin-server
dockerfile: resource/docker/spacegate-admin-server/Dockerfile
registry: docker.io
image: ecfront/spacegate-admin-server
tags: ${{ github.ref_name }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}