Blog
首页
文档
收藏
关于
  • 在线转换时间戳 (opens new window)
  • 在线压缩图片 (opens new window)
  • Float-Double转二进制 (opens new window)
  • 文件转Hex字符串 (opens new window)

HiuZing

🍑
首页
文档
收藏
关于
  • 在线转换时间戳 (opens new window)
  • 在线压缩图片 (opens new window)
  • Float-Double转二进制 (opens new window)
  • 文件转Hex字符串 (opens new window)
  • Nginx

  • Docker

  • CICD

    • GitHub Actions
      • 前言
      • 项目打包和部署
      • 自动化Docker镜像
  • Server

  • Linux

  • Windows

  • 运维
  • CICD
HiuZing
2025-12-22
目录

GitHub Actions

# 前言

至少一个细节:.github/workflows/xxx.yml

on:push

jobs:
	job1:
		runs-on:ubuntu-lastest
		steps:
		- run:pwd
		- run:ls
	job2:
		steps:
		- run:node --versionq
1
2
3
4
5
6
7
8
9
10
11

# 项目打包和部署

GitHub项目-Actions-New workflow

name:打包react项目
on:push

permissions:
	contents:write

jobs:
	name:npm-build工作
	runs-on:ubuntu-lastest
	
	steps:
	- name :读取仓库
	- uses:actions/checkout@v4
	
	- name:安装依赖+打包
	  run: |
	  	npm install
	  	npm run build
	  
	  name:部署
	  uses:JamesIves/github-pages-deploy-action@v4
	  with:
	  	branch:gh-pages
	  	folder:build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

跑完后会多一个gh-pages分支

进行仓库设置Settings

找到左侧的Pages-Github Pages-Build and deployment-Branch-选择分支-Save

回到Actions工作流的图即可打开部署后的项目

# 自动化Docker镜像

在以上的文件夹内,添加Dockerfile文件

在Docker Hub新建仓库(用于告知Actions推送的仓库)- 在我的账号-安全Security-New Access Token-Copy Access Token

name:构建镜像并推送到Docker Hub
on:push

jobs:
	name:npm-build工作
	runs-on:ubuntu-lastest
	
	steps:
	- name :读取仓库
	- uses:actions/checkout@v4
	
	- name:登录DockerHub
	  uses:actions/login-action@v3
	  with:
	  	usesname:${{secrets.DOCKER_HUB_USERNAME}}
	  	password:${{secrets.DOCKER_HUB_TOKEN}}
	  	
 	- name:构建并推送
 	  uses:docker/build-push-action@v5
 	  with:
 	    push:true
 	    tags:eggtoopain/react-app:latest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

回到仓库,左侧Secrets and variables-Actions-Repository secrets-New repository secret-新增名称和密钥(DOCKER_HUB_USERNAME和密钥)-新增账号Token(DOCKER_HUB_TOKEN和token)

上次更新: 2025/12/22, 14:54:34
分享社区
远程连接

← 分享社区 远程连接→

最近更新
01
分享社区
12-16
02
保存镜像
12-16
03
容器
12-13
更多文章>
Theme by Vdoing | Copyright © 2021-2025 WeiXiaojing | 友情链接
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式