-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (84 loc) · 2.97 KB
/
docker-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
name: Docker images build and push
on:
push:
branches: [ "main" ]
paths:
- 'actions-time.txt'
# schedule:
# - cron: "0 0 12 * *" # 每天12点
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
with:
persist-credentials: false
fetch-depth: 0
- name: Get latest release version
run: |
latest_version=$(curl -s https://api.github.com/repos/MCSManager/MCSManager/releases/latest | jq -r .tag_name)
echo "latest_version=$latest_version" >> $GITHUB_ENV
- name: Check local version
run: |
if [ -f ./MCSManager_version ]; then
local_version=$(cat ./MCSManager_version)
else
local_version="none"
fi
echo "local_version=$local_version" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.7.1
- name: Login to DockerHub
uses: docker/login-action@v3.3.0
with:
username: 1lkei
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker build-push daemon
uses: docker/build-push-action@v6.9.0
with:
context: .
file: Dockerfile.daemon
push: true # push to docker hub
tags: |
1lkei/mcsmanager-daemon:latest
1lkei/mcsmanager-daemon:${{ env.latest_version }}
build-args: |
LATEST_TAG=${{ env.latest_version }}
platforms: linux/amd64,linux/arm64
- name: Docker build-push daemon_debian
uses: docker/build-push-action@v6.9.0
with:
context: .
file: Dockerfile.daemon_debian
push: true # push to docker hub
tags: |
1lkei/mcsmanager-daemon:debian
1lkei/mcsmanager-daemon:debian-${{ env.latest_version }}
build-args: |
LATEST_TAG=${{ env.latest_version }}
platforms: linux/amd64,linux/arm64
- name: Docker build-push web
uses: docker/build-push-action@v6.9.0
with:
context: .
file: Dockerfile.web
push: true # push to docker hub
tags: |
1lkei/mcsmanager-web:latest
1lkei/mcsmanager-web:${{ env.latest_version }}
build-args: |
LATEST_TAG=${{ env.latest_version }}
platforms: linux/amd64,linux/arm64
- name: Commit updated version
if: env.local_version != env.latest_version
run: |
echo "$latest_version" > MCSManager_version
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add MCSManager_version
git commit -m "Update version to $latest_version"
git remote set-url origin https://1lkei:${{ secrets.REPO_BOT }}@github.com/1lkei/test.git
git push