forked from Viren070/AIOStreams
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (127 loc) · 4.32 KB
/
Copy pathdev-docker.yml
File metadata and controls
144 lines (127 loc) · 4.32 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
name: Dev Docker Image
on:
workflow_dispatch:
inputs:
ref:
description: 'Branch name or PR number (e.g. my-feature or 42)'
required: true
type: string
tag:
description: 'Override the image tag (optional, default: pr-<N> or <branch-name>)'
required: false
type: string
jobs:
setup:
name: Resolve ref
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.resolve.outputs.ref }}
tag: ${{ steps.resolve.outputs.tag }}
steps:
- name: Resolve ref and tag
id: resolve
env:
INPUT_REF: ${{ inputs.ref }}
INPUT_TAG: ${{ inputs.tag }}
run: |
if [[ "$INPUT_REF" =~ ^[0-9]+$ ]]; then
RESOLVED_REF="refs/pull/${INPUT_REF}/merge"
DEFAULT_TAG="pr-${INPUT_REF}"
else
RESOLVED_REF="${INPUT_REF}"
# Strip conventional prefixes (feat/, fix/, chore/, etc.), then sanitise
STRIPPED=$(echo "$INPUT_REF" | sed -E 's|^[a-z]+/||')
SAFE=$(echo "$STRIPPED" | tr '/' '-' | tr -cd 'a-zA-Z0-9._-' | sed 's/^-*//')
DEFAULT_TAG="${SAFE}"
fi
FINAL_TAG="${INPUT_TAG:-$DEFAULT_TAG}"
echo "ref=${RESOLVED_REF}" >> $GITHUB_OUTPUT
echo "tag=${FINAL_TAG}" >> $GITHUB_OUTPUT
echo "Resolved ref: ${RESOLVED_REF}, tag: ghcr.io/${{ github.repository_owner }}/aiostreams:${FINAL_TAG}"
build:
name: build (${{ matrix.suffix }})
needs: setup
permissions:
packages: write
contents: read
strategy:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
suffix: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
suffix: arm64
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ needs.setup.outputs.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Buildx
uses: docker/setup-buildx-action@v4
- uses: actions/setup-node@v6
with:
node-version: 24
- name: Get commit hash
id: commit
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Generate metadata
run: node scripts/generateMetadata.cjs --channel=dev --ref=${{ needs.setup.outputs.tag }} --commit=${{ steps.commit.outputs.sha }}
- name: Build & Push
id: build
uses: docker/build-push-action@v7
with:
platforms: ${{ matrix.platform }}
push: true
context: .
file: ./Dockerfile
outputs: type=image,name=ghcr.io/viren070/aiostreams,push-by-digest=true,name-canonical=true
cache-from: type=gha,scope=${{ matrix.suffix }}
cache-to: type=gha,mode=max,scope=${{ matrix.suffix }}
- name: Export digest
run: echo "${{ steps.build.outputs.digest }}" > "/tmp/${{ matrix.suffix }}"
- name: Upload digest artifact
uses: actions/upload-artifact@v7
with:
path: /tmp/${{ matrix.suffix }}
archive: false
retention-days: 1
merge:
name: Merge manifests
needs: [setup, build]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Download digests
uses: actions/download-artifact@v8
with:
path: /tmp/digests
pattern: '{amd64,arm64}'
merge-multiple: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Buildx
uses: docker/setup-buildx-action@v4
- name: Create and push manifest
env:
TAG: ${{ needs.setup.outputs.tag }}
run: |
docker buildx imagetools create \
-t "ghcr.io/viren070/aiostreams:${TAG}" \
"ghcr.io/viren070/aiostreams@$(cat /tmp/digests/amd64)" \
"ghcr.io/viren070/aiostreams@$(cat /tmp/digests/arm64)"