Skip to content

Create README.md

Create README.md #13

# .github/workflows/build-and-push.yml
name: Build and Push Docker Image
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get current date for tagging
run: echo "DATE_TAG=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 核心修改点在这里
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
# 修改 'images' 参数,使用固定的镜像名
# github.repository_owner 会自动获取你的 GitHub 用户名或组织名
images: ghcr.io/${{ github.repository_owner }}/python-code-server
# 标签规则保持不变
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,format=short
type=raw,value=${{ env.DATE_TAG }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}