Skip to content

修改 action中的脚本 #27

修改 action中的脚本

修改 action中的脚本 #27

Workflow file for this run

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: Build Docker Image
# 当 push 到 master 分支,或者创建以 v 开头的 tag 时触发,可根据需求修改
on:
push:
branches:
- master
tags:
- v*
env:
REGISTRY: ghcr.io
IMAGE: BanKnight/nvless
jobs:
build-and-push:
runs-on: ubuntu-latest
# 这里用于定义 GITHUB_TOKEN 的权限
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
# 登录到 GitHub Packages 容器仓库
# 注意 secrets.GITHUB_TOKEN 不需要手动添加,直接就可以用
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 根据输入自动生成 tag 和 label 等数据,说明见下
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE }}
# 构建并上传
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}