Skip to content

Commit 065d58b

Browse files
author
Sherrie Wang
committed
adding all apptainer related files for tagging
1 parent bb85c32 commit 065d58b

File tree

5 files changed

+142
-0
lines changed

5 files changed

+142
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
mkdir -p artifacts
4+
mkdir -p wave_images
5+
6+
for env_yaml in environments/*.yml; do
7+
image_name=$(head -n 1 $env_yaml | cut -d ' ' -f 2)
8+
echo "building image ${image_name} from file ${env_yaml}..."
9+
wave \
10+
--conda-file ${env_yaml} \
11+
--singularity \
12+
--freeze \
13+
--await \
14+
--output json \
15+
| python -m json.tool \
16+
| tee wave_images/${image_name}.json
17+
echo "done building image ${image_name}"
18+
cp wave_images/${image_name}.json artifacts/
19+
20+
done
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
wget https://raw.githubusercontent.com/apptainer/apptainer/main/tools/install-unprivileged.sh
6+
7+
chmod +x install-unprivileged.sh
8+
9+
mkdir -p /opt/shared/apptainer-1.3.2
10+
11+
./install-unprivileged.sh /opt/shared/apptainer
12+
13+
echo "/opt/apptainer/bin" >> $GITHUB_PATH
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
wget https://github.com/seqeralabs/wave-cli/releases/download/v1.4.1/wave-1.4.1-linux-x86_64
6+
7+
mv wave-1.4.1-linux-x86_64 wave
8+
9+
chmod +x wave
10+
11+
mkdir -p ~/wave/bin
12+
13+
mv wave ~/wave/bin
14+
15+
echo "~/wave/bin" >> $GITHUB_PATH
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env python
2+
3+
import argparse
4+
import glob
5+
import json
6+
import os
7+
import subprocess
8+
9+
10+
def pull_image(image_url, destination_image_file):
11+
"""
12+
"""
13+
apptainer_pull_cmd = [
14+
"apptainer",
15+
"pull",
16+
destination_image_file,
17+
image_url,
18+
]
19+
subprocess.run(apptainer_pull_cmd)
20+
21+
22+
def push_image(source_image_file, image_url):
23+
"""
24+
"""
25+
26+
apptainer_push_cmd = [
27+
"apptainer",
28+
"push",
29+
source_image_file,
30+
image_url,
31+
]
32+
subprocess.run(apptainer_push_cmd)
33+
34+
35+
def main(args):
36+
repo_owner = os.environ['GITHUB_REPOSITORY_OWNER'].lower()
37+
38+
wave_jsons = glob.glob(os.path.join(args.wave_jsons_dir, "*.json"))
39+
for wave_json in wave_jsons:
40+
with open(wave_json, 'r') as f:
41+
w = json.load(f)
42+
pull_image_url = w['containerImage']
43+
image_name_with_version = pull_image_url.split('/')[-1]
44+
image_name, image_version = image_name_with_version.split(':')
45+
pull_destination = os.path.join(args.images_dir, f"{image_name}--{image_version}.img")
46+
pull_image(pull_image_url, pull_destination)
47+
48+
push_image_url = f"oras://ghcr.io/{repo_owner}/{image_name}:{image_version}"
49+
push_image(pull_destination, push_image_url)
50+
51+
52+
if __name__ == '__main__':
53+
parser = argparse.ArgumentParser()
54+
parser.add_argument('--wave-jsons-dir')
55+
parser.add_argument('--images-dir')
56+
args = parser.parse_args()
57+
main(args)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and Push Container Images file
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
workflow_dispatch:
8+
9+
env:
10+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11+
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
12+
13+
jobs:
14+
build_and_push:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
packages: write
18+
contents: read
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Install Apptainer
22+
run: |
23+
.github/scripts/install_apptainer.sh
24+
- name: Check Apptainer installation
25+
run: apptainer --version
26+
- name: Install Wave CLI
27+
run: |
28+
.github/scripts/install_wave-cli.sh
29+
- name: Check wave installation
30+
run: wave --version
31+
- name: Build images
32+
run: |
33+
.github/scripts/build_container_images_wave.sh
34+
- name: Push images
35+
run: |
36+
echo ${GITHUB_TOKEN} | apptainer registry login -u ${GHCR_USERNAME} --password-stdin oras://ghcr.io
37+
.github/scripts/push_container_images_wave.py --wave-jsons-dir wave_images --images-dir wave_images

0 commit comments

Comments
 (0)