Skip to content

Commit e1e990a

Browse files
committed
Setup release workflows
1 parent a97eeb1 commit e1e990a

3 files changed

Lines changed: 131 additions & 3 deletions

File tree

.github/workflows/edge.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ on:
88
- main
99

1010
jobs:
11-
push:
11+
edge:
12+
name: Build Edge Image
1213
runs-on: ubuntu-latest
1314
steps:
1415
- name: Set up Docker Buildx

.github/workflows/pr.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
fail-on-error: true
3737

3838
build-image:
39-
name: Build Docker Image
39+
name: Build Test Docker Image
4040
runs-on: ubuntu-latest
4141
needs: test
4242
if: needs.test.result == 'success'
@@ -66,7 +66,7 @@ jobs:
6666
retention-days: 1
6767

6868
integration-test:
69-
name: Integration Test (${{ matrix.resolution }})
69+
name: Run Integration Test (${{ matrix.resolution }})
7070
runs-on: ubuntu-latest
7171
needs: [test, build-image]
7272
if: needs.test.result == 'success' && needs.build-image.result == 'success'

.github/workflows/release.yaml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Release Image Workflow
2+
# This workflow triggers on version tags (v*) and either:
3+
# 1. Re-tags an existing edge image with the same SHA, or
4+
# 2. Builds a new image if no matching edge image exists
5+
# Then it creates a GitHub release with the image details.
6+
name: Create Release For Version
7+
8+
on:
9+
push:
10+
tags:
11+
- 'v*'
12+
13+
jobs:
14+
wait-for-edge:
15+
name: Wait for Edge Workflows
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Wait for Edge workflows to complete
19+
uses: lewagon/wait-on-check-action@v1.4.0
20+
with:
21+
ref: ${{ github.sha }}
22+
check-name: 'edge' # Job name from edge.yaml
23+
repo-token: ${{ secrets.GITHUB_TOKEN }}
24+
wait-interval: 10
25+
allowed-conclusions: success,failure,cancelled,skipped
26+
27+
release:
28+
name: Create Release
29+
runs-on: ubuntu-latest
30+
needs: wait-for-edge
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v5
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v3
37+
38+
- name: Login to GitHub Container Registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Check If Image Exists For This SHA
46+
id: check_image
47+
run: |
48+
echo "Checking for edge image with SHA: ${{ github.sha }}"
49+
50+
# Check if image with current SHA exists
51+
if docker manifest inspect ghcr.io/zozman/stream-webpage-container:sha-${{ github.sha }} >/dev/null 2>&1; then
52+
echo "Edge image found for SHA ${{ github.sha }}"
53+
echo "image_exists=true" >> $GITHUB_OUTPUT
54+
else
55+
echo "No edge image found for SHA ${{ github.sha }}"
56+
echo "image_exists=false" >> $GITHUB_OUTPUT
57+
fi
58+
59+
- name: Re-tag Existing Image
60+
if: steps.check_image.outputs.image_exists == 'true'
61+
run: |
62+
echo "Re-tagging existing image..."
63+
64+
# Pull the existing image
65+
docker pull ghcr.io/zozman/stream-webpage-container:sha-${{ github.sha }}
66+
67+
# Tag with latest and version
68+
docker tag ghcr.io/zozman/stream-webpage-container:sha-${{ github.sha }} ghcr.io/zozman/stream-webpage-container:latest
69+
docker tag ghcr.io/zozman/stream-webpage-container:sha-${{ github.sha }} ghcr.io/zozman/stream-webpage-container:${{ github.ref_name }}
70+
71+
# Push the new tags
72+
docker push ghcr.io/zozman/stream-webpage-container:latest
73+
docker push ghcr.io/zozman/stream-webpage-container:${{ github.ref_name }}
74+
75+
- name: Generate Docker Metadata For New Build
76+
if: steps.check_image.outputs.image_exists == 'false'
77+
id: meta
78+
uses: docker/metadata-action@v5
79+
with:
80+
images: ghcr.io/zozman/stream-webpage-container
81+
tags: |
82+
type=raw,value=latest
83+
type=raw,value=${{ github.ref_name }}
84+
type=sha
85+
type=sha,format=long
86+
87+
- name: Build & Push New Docker Image
88+
if: steps.check_image.outputs.image_exists == 'false'
89+
uses: docker/build-push-action@v6
90+
with:
91+
push: true
92+
platforms: linux/amd64
93+
context: .
94+
tags: ${{ steps.meta.outputs.tags }}
95+
labels: ${{ steps.meta.outputs.labels }}
96+
97+
- name: Docker Actions Summary
98+
run: |
99+
if [ "${{ steps.check_image.outputs.image_exists }}" == "true" ]; then
100+
echo "✅ Successfully re-tagged existing edge image"
101+
echo "🏷️ Tags: latest, ${{ github.ref_name }}"
102+
else
103+
echo "✅ Successfully built and tagged new image"
104+
echo "🏷️ Tags: latest, ${{ github.ref_name }}, sha-${{ github.sha }}, sha-$(echo ${{ github.sha }} | cut -c1-12)"
105+
fi
106+
107+
- name: Create GitHub Release
108+
uses: softprops/action-gh-release@v2
109+
with:
110+
tag_name: ${{ github.ref_name }}
111+
name: Release ${{ github.ref_name }}
112+
body: |
113+
## Release ${{ github.ref_name }}
114+
115+
🐳 **Docker Images:**
116+
- `ghcr.io/zozman/stream-webpage-container:latest`
117+
- `ghcr.io/zozman/stream-webpage-container:${{ github.ref_name }}`
118+
119+
📝 **Image Details:**
120+
- **SHA:** `${{ github.sha }}`
121+
- **Built from:** ${{ steps.check_image.outputs.image_exists == 'true' && 'Re-tagged existing edge image' || 'Freshly built image' }}
122+
123+
## What's Changed
124+
See the [commit history](https://github.com/${{ github.repository }}/commits/${{ github.ref_name }}) for detailed changes.
125+
draft: false
126+
prerelease: false
127+
generate_release_notes: true

0 commit comments

Comments
 (0)