File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # .github/workflows/build-and-push.yml
2+
3+ name : Build and Push Docker Image
4+
5+ on :
6+ push :
7+ branches :
8+ - main
9+ workflow_dispatch :
10+
11+ jobs :
12+ build-and-push :
13+ runs-on : ubuntu-latest
14+ permissions :
15+ contents : read
16+ packages : write
17+
18+ steps :
19+ - name : Checkout repository
20+ uses : actions/checkout@v4
21+
22+ - name : Get current date for tagging
23+ run : echo "DATE_TAG=$(date +'%Y%m%d')" >> $GITHUB_ENV
24+
25+ - name : Log in to the Container registry
26+ uses : docker/login-action@v3
27+ with :
28+ registry : ghcr.io
29+ username : ${{ github.actor }}
30+ password : ${{ secrets.GITHUB_TOKEN }}
31+
32+ # 核心修改点在这里
33+ - name : Extract metadata (tags, labels) for Docker
34+ id : meta
35+ uses : docker/metadata-action@v5
36+ with :
37+ # 修改 'images' 参数,使用固定的镜像名
38+ # github.repository_owner 会自动获取你的 GitHub 用户名或组织名
39+ images : ghcr.io/${{ github.repository_owner }}/python-code-server
40+
41+ # 标签规则保持不变
42+ tags : |
43+ type=raw,value=latest,enable={{is_default_branch}}
44+ type=sha,format=short
45+ type=raw,value=${{ env.DATE_TAG }}
46+
47+ - name : Build and push Docker image
48+ uses : docker/build-push-action@v5
49+ with :
50+ context : .
51+ push : true
52+ tags : ${{ steps.meta.outputs.tags }}
53+ labels : ${{ steps.meta.outputs.labels }}
You can’t perform that action at this time.
0 commit comments