Skip to content

Commit

Permalink
Update docker-image-2.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
xwm111 authored Apr 3, 2024
1 parent b75e3e0 commit 04fe3d5
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/docker-image-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,38 @@ name: Docker Image CI

on:
push:
branches: [ "main" ]
tags:
- v1.**
pull_request:
branches: [ "main" ]
branches: [ main ] # 或者你希望运行build job的分支
tags-ignore: [ '*' ] # 忽略tag,这样在push时不会触发package job
create: # 当创建一个新的tag时触发workflow
tags: [ '*' ] # 对所有tags触发

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: load source code
uses: actions/checkout@v4

- name: Setup Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install dependencies
run: |
npm install # Replace with your package manager if needed (e.g., yarn install)
ls
pwd
run: npm install # Replace with your package manager if needed (e.g., yarn install)
- name: Build project # Add your specific build command here (e.g., npm run build)
run: npm run build

package:
runs-on: ubuntu-latest
needs: build # package job需要在build job之后运行
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/') # 仅当触发事件是创建tag时运行
steps:
- name: Login to Aliyun Container Registry (ACR)
uses: aliyun/acr-login@v1 # 使用阿里云镜像服务action
with:
login-server: registry.cn-zhangjiakou.aliyuncs.com
region-id: cn-zhangjiakou
username: "${{ secrets.REGISTRY_USERNAME }}"
password: "${{ secrets.REGISTRY_PASSWORD }}"

- name: Build and Push Docker Image
env:
IMAGE_TAG: ${{ github.sha }} # 用于标记容器版本号
Expand Down

0 comments on commit 04fe3d5

Please sign in to comment.