-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (104 loc) · 3.54 KB
/
nightly.yml
File metadata and controls
120 lines (104 loc) · 3.54 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Docker Image (Nightly)
on:
schedule:
# Run every night at 5:00 UTC
- cron: '0 5 * * *'
workflow_dispatch: # Allow manual trigger
env:
REGISTRY: docker.io
IMAGE_NAME: sillyangel/mice
jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get full history to check for changes
ref: dev # Always checkout dev branch
- name: Check for commits in last 24 hours
id: check
run: |
# Check if there are commits in the last 24 hours on dev branch
COMMITS=$(git log --since="24 hours ago" --oneline | wc -l)
echo "Commits in last 24 hours: $COMMITS"
if [ "$COMMITS" -gt 0 ]; then
echo "Changes detected - will build"
echo "should_build=true" >> $GITHUB_OUTPUT
else
echo "No changes in last 24 hours - skipping build"
echo "should_build=false" >> $GITHUB_OUTPUT
fi
push_to_registry:
runs-on: ubuntu-latest
needs: check_changes
if: needs.check_changes.outputs.should_build == 'true'
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: dev # Always checkout dev branch
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Get version from package.json
id: app_version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Docker metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=nightly
type=raw,value=dev-latest
labels: |
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
org.opencontainers.image.licenses=MIT
org.opencontainers.image.description=Nightly development build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
network=host
- name: Build and push
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: |
${{ steps.meta.outputs.labels }}
org.opencontainers.image.description=$(cat README.md | head -20 | tr '\n' ' ')
org.opencontainers.image.documentation=https://github.com/sillyangel/mice/blob/main/README.md
platforms: |
linux/amd64
linux/arm64/v8
cache-from: |
type=gha,scope=deps-only
cache-to: |
type=gha,mode=max,scope=deps-only
# - name: Docker Hub Description
# uses: peter-evans/dockerhub-description@v4
# with:
# username: ${{ vars.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# repository: sillyangel/mice