Skip to content

Commit dd403c0

Browse files
committed
ci: add isolated prod/dev streams with GHCR dev publishing
Introduce reusable CI and stream-specific callers for altinity (prod) and dev (integration), with optional e2e execution gated by CI_RUN_OPTIONAL repo variable and workflow_dispatch override. Add dedicated dev Docker publish workflow to GHCR and optional manual promotion workflow to retag vetted dev digests into DockerHub prod tags.
1 parent 48529c1 commit dd403c0

5 files changed

Lines changed: 457 additions & 0 deletions

File tree

.github/workflows/ci-dev.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI Dev
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
pull_request:
8+
branches:
9+
- dev
10+
workflow_dispatch:
11+
inputs:
12+
run_optional:
13+
description: "Run optional e2e suites (overrides repo variable)"
14+
required: false
15+
default: "false"
16+
type: choice
17+
options:
18+
- "false"
19+
- "true"
20+
21+
jobs:
22+
ci:
23+
uses: ./.github/workflows/reusable-ci.yml
24+
with:
25+
stream: dev
26+
run_e2e: true
27+
run_optional: ${{ fromJSON((github.event_name == 'workflow_dispatch' && github.event.inputs.run_optional) || vars.CI_RUN_OPTIONAL || 'false') }}
28+
go_version: "1.24.13"

.github/workflows/ci-prod.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI Prod
2+
3+
on:
4+
push:
5+
branches:
6+
- altinity
7+
pull_request:
8+
branches:
9+
- altinity
10+
workflow_dispatch:
11+
inputs:
12+
run_optional:
13+
description: "Run optional e2e suites (overrides repo variable)"
14+
required: false
15+
default: "false"
16+
type: choice
17+
options:
18+
- "false"
19+
- "true"
20+
21+
jobs:
22+
ci:
23+
uses: ./.github/workflows/reusable-ci.yml
24+
with:
25+
stream: prod
26+
run_e2e: true
27+
run_optional: ${{ fromJSON((github.event_name == 'workflow_dispatch' && github.event.inputs.run_optional) || vars.CI_RUN_OPTIONAL || 'false') }}
28+
go_version: "1.24.13"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and Push Dev Docker Image (GHCR)
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- dev
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: altinity/transferia-dev
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Set tag variables
30+
id: vars
31+
shell: bash
32+
run: |
33+
echo "short_sha=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
34+
echo "stamp=$(date -u +%Y%m%d-%H%M)" >> "$GITHUB_OUTPUT"
35+
36+
- name: Log in to GHCR
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Extract metadata (tags, labels)
44+
id: meta
45+
uses: docker/metadata-action@v5
46+
with:
47+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48+
tags: |
49+
type=raw,value=dev-latest
50+
type=sha,prefix=dev-,format=short
51+
type=raw,value=dev-${{ steps.vars.outputs.stamp }}-${{ steps.vars.outputs.short_sha }}
52+
type=ref,event=branch,prefix=dev-branch-,enable=${{ github.ref_name != 'dev' }}
53+
54+
- name: Build and push Docker image
55+
uses: docker/build-push-action@v6
56+
with:
57+
context: .
58+
platforms: linux/amd64,linux/arm64
59+
push: true
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}
62+
cache-from: type=gha
63+
cache-to: type=gha,mode=max
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Promote Dev Image to Prod Tags
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
source_digest:
7+
description: "Dev image digest from GHCR (sha256:...)"
8+
required: true
9+
target_tags:
10+
description: "Comma-separated DockerHub tags to update"
11+
required: true
12+
default: "altinity,latest"
13+
14+
env:
15+
SOURCE_REGISTRY: ghcr.io
16+
SOURCE_IMAGE: altinity/transferia-dev
17+
TARGET_REGISTRY: docker.io
18+
TARGET_IMAGE: altinity/transferia
19+
20+
jobs:
21+
promote:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: read
26+
steps:
27+
- name: Validate inputs
28+
shell: bash
29+
run: |
30+
set -euo pipefail
31+
if [[ ! "${{ inputs.source_digest }}" =~ ^sha256:[a-f0-9]{64}$ ]]; then
32+
echo "Invalid digest format: ${{ inputs.source_digest }}"
33+
exit 1
34+
fi
35+
if [[ -z "${{ inputs.target_tags }}" ]]; then
36+
echo "target_tags cannot be empty"
37+
exit 1
38+
fi
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Log in to GHCR
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ${{ env.SOURCE_REGISTRY }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Log in to Docker Hub
51+
uses: docker/login-action@v3
52+
with:
53+
registry: ${{ env.TARGET_REGISTRY }}
54+
username: ${{ secrets.DOCKER_USERNAME }}
55+
password: ${{ secrets.DOCKER_PASSWORD }}
56+
57+
- name: Retag digest
58+
shell: bash
59+
run: |
60+
set -euo pipefail
61+
IFS=',' read -ra TAGS <<< "${{ inputs.target_tags }}"
62+
for tag in "${TAGS[@]}"; do
63+
clean_tag="$(echo "$tag" | xargs)"
64+
if [[ -z "$clean_tag" ]]; then
65+
continue
66+
fi
67+
echo "Promoting ${{ env.SOURCE_REGISTRY }}/${{ env.SOURCE_IMAGE }}@${{ inputs.source_digest }} -> ${{ env.TARGET_REGISTRY }}/${{ env.TARGET_IMAGE }}:${clean_tag}"
68+
docker buildx imagetools create \
69+
--tag "${{ env.TARGET_REGISTRY }}/${{ env.TARGET_IMAGE }}:${clean_tag}" \
70+
"${{ env.SOURCE_REGISTRY }}/${{ env.SOURCE_IMAGE }}@${{ inputs.source_digest }}"
71+
done

0 commit comments

Comments
 (0)