Create buidl_and_push_ghcr.yml
This commit is contained in:
35
.github/workflows/buidl_and_push_ghcr.yml
vendored
Normal file
35
.github/workflows/buidl_and_push_ghcr.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
name: Docker Image CI
|
||||||
|
|
||||||
|
# 触发条件改为手动
|
||||||
|
on:
|
||||||
|
workflow_dispatch: # 手动触发
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# 设置 Docker Buildx
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
# 登录 GitHub Container Registry
|
||||||
|
- name: Log in to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# 构建并推送 Docker 镜像,设置两个 tag
|
||||||
|
- name: Build and push Docker image
|
||||||
|
run: |
|
||||||
|
# 构建镜像并打上两个 tag
|
||||||
|
docker build . --file Dockerfile \
|
||||||
|
--tag ghcr.io/${{ github.repository }}/my-image-name:latest \
|
||||||
|
--tag ghcr.io/${{ github.repository }}/my-image-name:${{ github.sha }}
|
||||||
|
# 推送两个 tag
|
||||||
|
docker push ghcr.io/${{ github.repository }}/my-image-name:latest
|
||||||
|
docker push ghcr.io/${{ github.repository }}/my-image-name:${{ github.sha }}
|
||||||
Reference in New Issue
Block a user