-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (50 loc) · 1.92 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
name: 构建并推送Docker镜像
on:
# 定时任务,每天北京时间早上7点触发
schedule:
- cron: '0 7 * * *'
# 当代码推送到master分支时触发
push:
branches:
- master
env:
# 设置时区为亚洲/上海(北京时间)
TZ: Asia/Shanghai
jobs:
docker:
# 使用最新版的Ubuntu操作系统
runs-on: ubuntu-latest
steps:
- name: Checkout
# 拉取代码仓库到工作目录
uses: actions/checkout@v2
- name: Download and Unzip Upstream Source Code
# 下载和解压上游源代码(可能是依赖的项目或资源)
run: |
curl -OL https://github.com/sangxuesheng/lsky-pro-Docker/archive/refs/tags/1.0.zip
unzip *.zip
mv ./lsky-pro-master/* ./
mv ./lsky-pro-master/.env.example ./
rm -rf master.zip lsky-pro-master
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
# 设置PHP版本为8.1
php-version: '8.1'
- name: Copy .env
# 如果项目根目录下没有.env文件,则复制.env.example为.env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
# 使用Composer安装项目依赖
run: composer install
- name: Login to DockerHub
# 登录到DockerHub以准备推送镜像
uses: docker/login-action@v1
with:
# 使用GitHub仓库的Secrets中存储的DockerHub用户名和密码进行认证
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
# 构建Docker镜像,并推送到DockerHub的tingwensuojian用户下的lsky-pro-docker仓库的latest标签
run: |
docker build -t tingwensuojian/lsky-pro-docker:latest .
docker push tingwensuojian/lsky-pro-docker:latest