-
Notifications
You must be signed in to change notification settings - Fork 342
145 lines (119 loc) · 5.26 KB
/
publish-docker-manifest.yml
File metadata and controls
145 lines (119 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Docker Multi-arch Manifests
on:
workflow_run:
workflows:
- "Docker Proxy AMD64"
- "Docker Proxy ARM64"
- "Docker Full AMD64"
- "Docker Full ARM64"
- "Docker Offline AMD64"
- "Docker Offline ARM64"
types: [completed]
jobs:
check-builds:
name: Check if all builds succeeded
runs-on: ubuntu-latest
outputs:
all-success: ${{ steps.check.outputs.result }}
version: ${{ steps.version.outputs.VERSION }}
steps:
- name: Check workflow results
id: check
uses: actions/github-script@v7
with:
script: |
const workflows = [
"Docker Proxy AMD64",
"Docker Proxy ARM64",
"Docker Full AMD64",
"Docker Full ARM64",
"Docker Offline AMD64",
"Docker Offline ARM64"
];
const runId = context.payload.workflow_run.id;
const ref = context.payload.workflow_run.head_sha;
console.log(`Checking workflows for ref: ${ref}`);
// Get all workflow runs for this ref
const { data: runs } = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
head_sha: ref,
status: 'completed'
});
const workflowResults = {};
for (const run of runs.workflow_runs) {
if (workflows.includes(run.name)) {
workflowResults[run.name] = run.conclusion;
console.log(`${run.name}: ${run.conclusion}`);
}
}
// Check if all workflows succeeded
const allSuccess = workflows.every(name =>
workflowResults[name] === 'success'
);
console.log(`All workflows successful: ${allSuccess}`);
return allSuccess;
- name: Extract version from workflow
id: version
run: |
VERSION=$(echo "${{ github.event.workflow_run.head_branch }}" | sed 's/refs\/tags\///')
if [[ $VERSION != v* ]]; then
# If not a version tag, use the tag from the triggering release
VERSION="${{ github.event.workflow_run.head_branch }}"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
create-manifests:
name: Create multi-arch manifests
runs-on: ubuntu-latest
needs: check-builds
if: needs.check-builds.outputs.all-success == 'true'
permissions:
contents: read
packages: write
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create proxy multi-arch manifest
run: |
VERSION="${{ needs.check-builds.outputs.version }}"
# Create versioned proxy manifest
docker manifest create ghcr.io/${{ github.repository }}:${VERSION}-proxy \
ghcr.io/${{ github.repository }}:${VERSION}-proxy-amd64 \
ghcr.io/${{ github.repository }}:${VERSION}-proxy-arm64
docker manifest push ghcr.io/${{ github.repository }}:${VERSION}-proxy
# Create latest proxy manifest
docker manifest create ghcr.io/${{ github.repository }}:latest-proxy \
ghcr.io/${{ github.repository }}:latest-proxy-amd64 \
ghcr.io/${{ github.repository }}:latest-proxy-arm64
docker manifest push ghcr.io/${{ github.repository }}:latest-proxy
- name: Create full multi-arch manifest
run: |
VERSION="${{ needs.check-builds.outputs.version }}"
# Create versioned full manifest
docker manifest create ghcr.io/${{ github.repository }}:${VERSION} \
ghcr.io/${{ github.repository }}:${VERSION}-amd64 \
ghcr.io/${{ github.repository }}:${VERSION}-arm64
docker manifest push ghcr.io/${{ github.repository }}:${VERSION}
# Create latest full manifest
docker manifest create ghcr.io/${{ github.repository }}:latest \
ghcr.io/${{ github.repository }}:latest-amd64 \
ghcr.io/${{ github.repository }}:latest-arm64
docker manifest push ghcr.io/${{ github.repository }}:latest
- name: Create offline multi-arch manifest
run: |
VERSION="${{ needs.check-builds.outputs.version }}"
# Create versioned offline manifest
docker manifest create ghcr.io/${{ github.repository }}:${VERSION}-offline \
ghcr.io/${{ github.repository }}:${VERSION}-offline-amd64 \
ghcr.io/${{ github.repository }}:${VERSION}-offline-arm64
docker manifest push ghcr.io/${{ github.repository }}:${VERSION}-offline
# Create latest offline manifest
docker manifest create ghcr.io/${{ github.repository }}:latest-offline \
ghcr.io/${{ github.repository }}:latest-offline-amd64 \
ghcr.io/${{ github.repository }}:latest-offline-arm64
docker manifest push ghcr.io/${{ github.repository }}:latest-offline