-
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (55 loc) · 2.01 KB
/
Copy pathbuild.yml
File metadata and controls
65 lines (55 loc) · 2.01 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
name: Build Apptainer Container
on:
push:
branches: [main]
tags: ['*']
env:
REGISTRY: ghcr.io
# Hardcoded container name here
IMAGE_NAME: ${{ github.repository_owner }}/s3cmdc
jobs:
build-apptainer:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# fetch-depth: 0 is required for git describe to access the full tag history
fetch-depth: 0
- name: Extract SCM versions
id: scm
run: |
# Extracts the nearest tag, number of commits since the tag, and the abbreviated commit hash.
# Example output: 1.0.1-4-g1a2b3c4. If no tags exist, the commit SHA is returned.
RAW_VERSION=$(git describe --tags --always)
# Sanitize the string for OCI registry compatibility
CLEAN_VERSION=$(echo "$RAW_VERSION" | tr '+' '-')
echo "tag_version=$CLEAN_VERSION" >> "$GITHUB_OUTPUT"
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=sha,format=short
type=raw,value=${{ steps.scm.outputs.tag_version }}
- name: Setup Apptainer
uses: eWaterCycle/setup-apptainer@v2
with:
apptainer-version: 1.3.1
- name: Build Apptainer image
run: |
sudo apptainer build container.sif containers/s3cmdc.def
- name: Push Apptainer image to GHCR
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | apptainer registry login -u ${{ github.actor }} --password-stdin oras://${{ env.REGISTRY }}
# Clean way to loop through tags even if they have weird spacing
TAGS="${{ steps.meta.outputs.tags }}"
for TAG in $TAGS; do
echo "Pushing to oras://$TAG"
apptainer push container.sif "oras://$TAG"
done