Skip to content

Commit

Permalink
feat: Add creation of RPM and Debian repos
Browse files Browse the repository at this point in the history
  • Loading branch information
neilmunday committed Mar 23, 2024
1 parent c61dfa0 commit 670dfc0
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 2 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]


workflow_run:
workflows: ["Test and release"]
types:
- completed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -32,18 +36,31 @@ jobs:
run: |
cp README.md pages/index.md
cp CHANGELOG.md TEMPLATES.md pages/
mkdir -p pages/tests/unit pages/tests/integration pages/tests/integration/docker-slurm
mkdir -p pages/repo pages/tests/unit pages/tests/integration pages/tests/integration/docker-slurm
cp tests/unit/README.md pages/tests/unit/index.md
cp tests/integration/README.md pages/tests/integration/index.md
cp tests/integration/docker-slurm/README.md pages/tests/integration/docker-slurm/index.md
sed -i 's#../../#https://github.com/neilmunday/slurm-mail/blob/main/#g' pages/tests/integration/index.md
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install required packages
run: |
sudo apt update
sudo apt install -y createrepo-c dpkg-dev
python -m pip install --upgrade pip
pip install yq
- name: Create repos
env:
GH_TOKEN: ${{ github.token }}
run: |
build-tools/create-repos.sh -o $(realpath pages/repo) -u $(yq -r .url pages/_config.yml)
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./pages
destination: ./_site
- name: Set permissions on the _site directory
run: sudo chown -R runner:docker _site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

Expand Down
144 changes: 144 additions & 0 deletions build-tools/create-repos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/bin/bash

#
# This file is part of Slurm-Mail.
#
# Slurm-Mail is a drop in replacement for Slurm's e-mails to give users
# much more information about their jobs compared to the standard Slurm
# e-mails.
#
# Copyright (C) 2018-2024 Neil Munday (neil@mundayweb.com)
#
# Slurm-Mail is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# Slurm-Mail is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Slurm-Mail. If not, see <http://www.gnu.org/licenses/>.
#

#
# This is a helper script to create package repos for the latest
# release of Slurm-Mail.
#

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source $DIR/common.sh

function usage {
echo "Usage: $0 -o path -u url" 1>&2
echo " -o output path"
echo " -u site URL"
exit 1
}

while getopts ":o:u:" options; do
case "${options}" in
o)
OUTPUT_DIR=${OPTARG}
;;
u)
SITE_URL=${OPTARG}
;;
:)
echo "Error: -${OPTARG} requires a value"
usage
;;
*)
usage
;;
esac
done

if [ -z $OUTPUT_DIR ] || [ -z $SITE_URL ]; then
usage
fi

check_dir $OUTPUT_DIR

echo "repos will be written to: $OUTPUT_DIR"

RHEL_OSES="
amzn2
el7
el8
el9
sl15
"

for OS in $RHEL_OSES; do
cd $DIR
echo "processing: $OS"
REPO_DIR="$OUTPUT_DIR/$OS"
mkdir -p $REPO_DIR
echo "downloading RPM..."
gh release download --pattern "*${OS}.noarch.rpm" -D $REPO_DIR
echo "creating repo"
cd $REPO_DIR
createrepo_c .
cat << EOF_REPO > $OUTPUT_DIR/slurm-mail.$OS.repo
[slurm-mail]
name=Slurm-Mail Repo for $OS
baseurl=$SITE_URL/repo/$OS
enabled=1
gpgcheck=0
EOF_REPO
done

DEB_OSES="
ub20
ub22
"

for OS in $DEB_OSES; do
cd $DIR
echo "processing: $OS"
REPO_DIR="$OUTPUT_DIR/$OS"
echo "downloading DEB..."
gh release download --pattern "*${OS}-ubuntu1_all.deb" -D $REPO_DIR
cd $REPO_DIR
dpkg-scanpackages . /dev/null > Release
done

# create index page
cat << EOF_INDEX > $OUTPUT_DIR/index.md
# Slurm-Mail Repositories
Here you will find installation instructions for the operating systems supported by Slurm-Mail.
## RPM based operating systems
EOF_INDEX

for OS in $RHEL_OSES; do
cat << EOF_INDEX >> $OUTPUT_DIR/index.md
### $OS
\`\`\`bash
sudo wget -O /etc/yum.repos.d/slurm-mail.repo $SITE_URL/repo/slurm-mail.$OS.repo
\`\`\`
EOF_INDEX
done

cat << EOF_INDEX >> $OUTPUT_DIR/index.md
## Debian based operating systems
Add to your \`/etc/apt/sources.list\` file the following line depending on your OS.
EOF_INDEX

for OS in $DEB_OSES; do
cat << EOF_INDEX >> $OUTPUT_DIR/index.md
### $OS
\`\`\`
deb [trusted=yes] $SITE_URL ./
\`\`\`
EOF_INDEX
done

0 comments on commit 670dfc0

Please sign in to comment.