forked from Viren070/AIOStreams
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (75 loc) · 2.63 KB
/
dev-docker.yml
File metadata and controls
87 lines (75 loc) · 2.63 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
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:
build:
name: build
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
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}"
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ steps.resolve.outputs.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Node
uses: actions/setup-node@v4
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=${{ steps.resolve.outputs.tag }} --commit=${{ steps.commit.outputs.sha }}
- name: Build & Push
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: true
context: .
file: ./Dockerfile
tags: ghcr.io/viren070/aiostreams:${{ steps.resolve.outputs.tag }}