Repository navigation
142 lines (136 loc) · 4.85 KB
/
Copy pathdevcontainer.yml
File metadata and controls
142 lines (136 loc) · 4.85 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
name: devcontainer GHCR publication
on:
workflow_call:
inputs:
candidate:
type: boolean
required: false
default: false
outputs:
image_ref:
description: Immutable image reference.
value: ${{ jobs.publish.outputs.image_ref }}
permissions:
contents: read
jobs:
prepare:
if: github.repository == 'WasmEdge/devcontainer' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || inputs.candidate)
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.identity.outputs.tag }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- id: identity
env:
SOURCE_SHA: ${{ github.sha }}
RUN_ID: ${{ github.run_id }}
ATTEMPT: ${{ github.run_attempt }}
run: |
if [ '${{ inputs.candidate }}' = true ]; then
tag=$(python3 .github/scripts/devcontainer/publication.py candidate --pr '${{ github.event.number }}' \
--source-sha "$SOURCE_SHA" --run-id "$RUN_ID" --attempt "$ATTEMPT")
else
tag=$(python3 .github/scripts/devcontainer/publication.py tag \
--source-sha "$SOURCE_SHA" --run-id "$RUN_ID" --attempt "$ATTEMPT")
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
build:
needs: prepare
if: github.repository == 'WasmEdge/devcontainer' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || inputs.candidate)
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64
arch: amd64
- runner: ubuntu-24.04-arm
target: aarch64
arch: arm64
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push native platform
uses: docker/bake-action@59cb1203cd42bcefd40a1b6d73b589e48c86040e # v7.5.0
with:
source: .
files: docker-bake.ci-image-base.hcl
targets: ${{ matrix.target }}
push: true
set: |
${{ matrix.target }}.tags=ghcr.io/wasmedge/devcontainer:${{ needs.prepare.outputs.tag }}-stage-${{ matrix.arch }}
${{ matrix.target }}.labels.org.opencontainers.image.source=https://github.com/WasmEdge/devcontainer
${{ matrix.target }}.labels.org.opencontainers.image.revision=${{ github.sha }}
publish:
needs:
- prepare
- build
if: needs.build.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image_ref: ${{ steps.publish.outputs.image_ref }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Assemble multi-platform index
id: publish
env:
TAG: ${{ needs.prepare.outputs.tag }}
run: |
image=ghcr.io/wasmedge/devcontainer
docker buildx imagetools create --tag "$image:$TAG" \
"$image:$TAG-stage-amd64" "$image:$TAG-stage-arm64"
digest=$(docker buildx imagetools inspect "$image:$TAG" \
--format '{{json .Manifest.Digest}}' | tr -d '"')
if [ -z "$digest" ] || [ "$digest" = "null" ]; then
echo "Failed to obtain image digest" >&2
exit 1
fi
if [ '${{ inputs.candidate }}' != true ]; then
docker buildx imagetools create --tag "$image:latest" "$image@$digest"
fi
echo "image_ref=$image@$digest" >> "$GITHUB_OUTPUT"
summarize-publication:
needs:
- prepare
- publish
if: needs.publish.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Report published image
env:
IMAGE_REF: ${{ needs.publish.outputs.image_ref }}
TAG: ${{ needs.prepare.outputs.tag }}
run: |
image=ghcr.io/wasmedge/devcontainer
{
echo "## Published GHCR image"
echo
echo "- Immutable reference: \`$image:$TAG@${IMAGE_REF#*@}\`"
} >> "$GITHUB_STEP_SUMMARY"