-
Notifications
You must be signed in to change notification settings - Fork 11
73 lines (63 loc) · 2.18 KB
/
Copy pathdev-docker.yml
File metadata and controls
73 lines (63 loc) · 2.18 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
name: Dev Docker Build
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to build from (defaults to main)"
required: false
type: string
default: "main"
permissions:
contents: read
packages: write
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
docker:
name: "Build and push ${{ inputs.branch }}"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Generate image tag
id: tag
run: |
BRANCH="${{ inputs.branch }}"
# Sanitize branch name: replace any non-alphanumeric chars with -
SAFE_BRANCH=$(echo "$BRANCH" | sed 's/[^a-zA-Z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-\|-$//g')
TIMESTAMP=$(date -u +%Y%m%d%H%M%S)
echo "value=${SAFE_BRANCH}-test-img-${TIMESTAMP}" >> $GITHUB_OUTPUT
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64
provenance: false
tags: ghcr.io/skardilabs/skardi/skardi-server:${{ steps.tag.outputs.value }}
cache-from: type=gha,scope=dev-${{ inputs.branch }}
cache-to: type=gha,mode=max,scope=dev-${{ inputs.branch }}
- name: Summary
run: |
echo "### Docker image published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "docker pull ghcr.io/skardilabs/skardi/skardi-server:${{ steps.tag.outputs.value }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY