Skip to content

Commit c42aa86

Browse files
Dev docker flow: image publish only (#63)
* dev docker flow * add publish time * remove features
1 parent 41654ce commit c42aa86

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

.github/workflows/dev-docker.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Dev Docker Build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: "Branch to build from (defaults to main)"
8+
required: false
9+
type: string
10+
default: "main"
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
CARGO_INCREMENTAL: 0
19+
20+
jobs:
21+
docker:
22+
name: "Build and push ${{ inputs.branch }}"
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
ref: ${{ inputs.branch }}
29+
30+
- name: Generate image tag
31+
id: tag
32+
run: |
33+
BRANCH="${{ inputs.branch }}"
34+
# Sanitize branch name: replace any non-alphanumeric chars with -
35+
SAFE_BRANCH=$(echo "$BRANCH" | sed 's/[^a-zA-Z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-\|-$//g')
36+
TIMESTAMP=$(date -u +%Y%m%d%H%M%S)
37+
echo "value=${SAFE_BRANCH}-test-img-${TIMESTAMP}" >> $GITHUB_OUTPUT
38+
39+
- name: Free up disk space
40+
run: |
41+
sudo rm -rf /usr/share/dotnet
42+
sudo rm -rf /opt/ghc
43+
sudo rm -rf /usr/local/share/boost
44+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
- name: Log in to GitHub Container Registry
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ghcr.io
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Build and push Docker image
57+
uses: docker/build-push-action@v6
58+
with:
59+
context: .
60+
push: true
61+
platforms: linux/amd64
62+
provenance: false
63+
tags: ghcr.io/skardilabs/skardi/skardi-server:${{ steps.tag.outputs.value }}
64+
cache-from: type=gha,scope=dev-${{ inputs.branch }}
65+
cache-to: type=gha,mode=max,scope=dev-${{ inputs.branch }}
66+
67+
- name: Summary
68+
run: |
69+
echo "### Docker image published" >> $GITHUB_STEP_SUMMARY
70+
echo "" >> $GITHUB_STEP_SUMMARY
71+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
72+
echo "docker pull ghcr.io/skardilabs/skardi/skardi-server:${{ steps.tag.outputs.value }}" >> $GITHUB_STEP_SUMMARY
73+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)