-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (122 loc) · 6.04 KB
/
Copy pathbuild-push-workflow.yml
File metadata and controls
151 lines (122 loc) · 6.04 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Build and Push Docker Images
on:
workflow_dispatch:
inputs:
SLURM_VERSION_OVERRIDE:
description: 'Optional: Specific Slurm version to build (e.g., 24-11-5-1). Leave empty to use latest.'
required: false
default: ''
pull_request:
branches:
- main
jobs:
build-scan-remediate-push:
name: Build and Push All Slurm Services
runs-on: ubuntu-latest
env:
DOCKER_REPO: ${{ vars.DOCKER_HUB_REPO }}
steps:
- name: 🛠️ Checkout Repository
uses: actions/checkout@v4
- name: 🎯 Determine Target Slurm Version
id: vars
run: |
set -e # Exit on error
# Install jq for JSON parsing
sudo apt-get update
sudo apt-get install -y jq curl
# Check if this is a manual dispatch with version override
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.SLURM_VERSION_OVERRIDE }}" ]; then
echo "✅ Using manual dispatch version override: ${{ github.event.inputs.SLURM_VERSION_OVERRIDE }}"
VERSION="${{ github.event.inputs.SLURM_VERSION_OVERRIDE }}"
else
echo "🔍 No version override set. Detecting latest stable version..."
# Fetch all tags from the SchedMD/slurm repo
TAGS=$(curl -s https://api.github.com/repos/SchedMD/slurm/tags | jq -r '.[].name')
# Filter for stable release tags (e.g., slurm-23-11-7-1) and get the latest
LATEST_TAG=$(echo "$TAGS" \
| grep -E '^slurm-[0-9]+-[0-9]+-[0-9]+-[0-9]+$' \
| sort -V \
| tail -n1)
if [ -z "$LATEST_TAG" ]; then
echo "❌ Could not determine the latest Slurm tag."
exit 1
fi
VERSION="${LATEST_TAG#slurm-}"
echo "🔬 Detected latest version: $VERSION"
fi
# Convert version format for deb file matching (e.g., 24-11-5-1 -> 24.11.5-1)
DEB_VERSION=$(echo "$VERSION" | sed 's/^\([0-9]*\)-\([0-9]*\)-\([0-9]*\)-\([0-9]*\)$/\1.\2.\3-\4/')
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "deb_version=${DEB_VERSION}" >> $GITHUB_OUTPUT
- name: 🛑 Check if DEBs for this version already exist
id: version-check
run: |
version="${{ steps.vars.outputs.version }}"
debver="${{ steps.vars.outputs.deb_version }}"
echo "🔍 Inputs:"
echo " Raw version = $version"
echo " Debian version = $debver"
echo " Search pattern = *_${debver}_*.deb"
# Check for existing DEBs in the slurm-debs directory
if [ -d "slurm-debs" ]; then
count=$(find "slurm-debs" -type f -name "*_${debver}_*.deb" | wc -l || true)
if [ "$count" -gt 0 ]; then
echo "✅ DEBs for Slurm $version found. Proceeding with Docker build."
echo "skip_build=false" >> $GITHUB_OUTPUT
else
echo "❌ No DEB files found for Slurm $version. Cannot proceed with Docker build."
echo "skip_build=true" >> $GITHUB_OUTPUT
fi
else
echo "❌ No slurm-debs directory found. Cannot proceed with Docker build."
echo "skip_build=true" >> $GITHUB_OUTPUT
fi
- name: ⏭️ Skip Build - No DEB Files
if: steps.version-check.outputs.skip_build == 'true'
run: |
echo "🚫 Skipping Docker build process"
echo " No DEB files found for Slurm version ${{ steps.vars.outputs.version }}"
echo " Please ensure DEB packages are built first using the build-and-commit-slurm-debs workflow"
- name: 🐳 Build and Push slurmctld
if: steps.version-check.outputs.skip_build == 'false'
run: |
echo "🔨 Building slurmctld..."
# Copy DEB files for this service
cp -v slurm-debs/*${{ steps.vars.outputs.deb_version }}*.deb ./slurmctld/
# Build with dual tags
cd slurmctld
docker build -t $DOCKER_REPO:slurmctld .
docker build -t $DOCKER_REPO:slurmctld-${{ steps.vars.outputs.version }} .
# Login and push both tags
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ vars.DOCKER_HUB_USER }}" --password-stdin
docker push $DOCKER_REPO:slurmctld
docker push $DOCKER_REPO:slurmctld-${{ steps.vars.outputs.version }}
- name: 🐳 Build and Push slurmdbd
if: steps.version-check.outputs.skip_build == 'false'
run: |
echo "🔨 Building slurmdbd..."
# Copy DEB files for this service
cp -v slurm-debs/*${{ steps.vars.outputs.deb_version }}*.deb ./slurmdbd/
# Build with dual tags
cd slurmdbd
docker build -t $DOCKER_REPO:slurmdbd .
docker build -t $DOCKER_REPO:slurmdbd-${{ steps.vars.outputs.version }} .
# Login and push both tags
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ vars.DOCKER_HUB_USER }}" --password-stdin
docker push $DOCKER_REPO:slurmdbd
docker push $DOCKER_REPO:slurmdbd-${{ steps.vars.outputs.version }}
- name: 🐳 Build and Push slurmrestd
if: steps.version-check.outputs.skip_build == 'false'
run: |
echo "🔨 Building slurmrestd..."
# Copy DEB files for this service
cp -v slurm-debs/*${{ steps.vars.outputs.deb_version }}*.deb ./slurmrestd/
# Build with dual tags
cd slurmrestd
docker build -t $DOCKER_REPO:slurmrestd .
docker build -t $DOCKER_REPO:slurmrestd-${{ steps.vars.outputs.version }} .
# Login and push both tags
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ vars.DOCKER_HUB_USER }}" --password-stdin
docker push $DOCKER_REPO:slurmrestd
docker push $DOCKER_REPO:slurmrestd-${{ steps.vars.outputs.version }}