|
8 | 8 | branches: |
9 | 9 | - main |
10 | 10 | workflow_dispatch: |
| 11 | + inputs: |
| 12 | + platform: |
| 13 | + description: 'Platform to build' |
| 14 | + required: false |
| 15 | + default: 'linux/amd64,linux/arm64' |
| 16 | + type: choice |
| 17 | + options: |
| 18 | + - linux/amd64,linux/arm64 |
| 19 | + - linux/amd64 |
11 | 20 |
|
12 | 21 | env: |
13 | 22 | # 使用 docker.io 作为 Docker Hub(如果为空) |
@@ -46,14 +55,21 @@ jobs: |
46 | 55 | username: ${{ github.actor }} |
47 | 56 | password: ${{ secrets.GITHUB_TOKEN }} |
48 | 57 |
|
| 58 | + - name: Generate timestamp |
| 59 | + id: timestamp |
| 60 | + run: echo "timestamp=$(date -u +'%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT |
| 61 | + |
49 | 62 | - name: Extract metadata |
50 | 63 | id: meta |
51 | 64 | uses: docker/metadata-action@v5 |
52 | 65 | with: |
53 | 66 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
54 | 67 | tags: | |
55 | 68 | type=raw,value=latest,priority=500 |
56 | | - type=raw,value=${{ github.run_number }},priority=400 |
| 69 | + type=raw,value=${{ steps.timestamp.outputs.timestamp }},priority=400 |
| 70 | + type=raw,value=secure-${{ steps.timestamp.outputs.timestamp }},priority=300 |
| 71 | + type=raw,value=secure-latest,priority=200 |
| 72 | + type=raw,value=main-${{ github.sha }},priority=100 |
57 | 73 |
|
58 | 74 | - name: Build and push Docker image |
59 | 75 | id: build-and-push |
|
66 | 82 | labels: ${{ steps.meta.outputs.labels }} |
67 | 83 | secrets: | |
68 | 84 | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} |
69 | | - platforms: linux/amd64, linux/arm64 |
70 | | - cache-from: type=gha |
71 | | - cache-to: type=gha,mode=max |
| 85 | + platforms: ${{ github.event.inputs.platform || 'linux/amd64,linux/arm64' }} |
| 86 | + cache-from: type=gha,scope=build |
| 87 | + cache-to: type=gha,mode=max,scope=build |
72 | 88 |
|
73 | 89 | - name: Attest Build Provenance |
74 | 90 | uses: actions/attest-build-provenance@v3 |
|
0 commit comments