-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (108 loc) · 3.66 KB
/
build-container.yml
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
name: Singularity Build (manual)
on:
# Manually run workflow
workflow_dispatch:
inputs:
tag:
description: "Tag for the built container"
required: true
default: "dev"
# Trigger on push
push:
# This recipe shows how to manually define a matrix of singularity recipes (paths) to build
# Edit the branches here if you want to change deploy behavior
branches:
- main
- master
# Trigger on PR
pull_request: []
# Trigger on published release
release:
types: [published]
jobs:
build-test-containers:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
recipe: ["Singularity"]
name: Check ${{ matrix.recipe }}
steps:
- name: Check Out Code for the Container Build
uses: actions/checkout@v2
- name: Continue if Singularity Recipe Exists
run: |
if [[ -f "${{ matrix.recipe }}" ]]; then
echo "keepgoing=true" >> $GITHUB_ENV
fi
- name: Set up Go 1.13
if: ${{ env.keepgoing == 'true' }}
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Install Dependencies
if: ${{ env.keepgoing == 'true' }}
run: |
sudo apt-get update && sudo apt-get install -y \
build-essential \
libssl-dev \
uuid-dev \
libgpgme11-dev \
squashfs-tools \
libseccomp-dev \
pkg-config
- name: Install Singularity
if: ${{ env.keepgoing == 'true' }}
env:
SINGULARITY_VERSION: 3.8.1
GOPATH: /tmp/go
run: |
mkdir -p $GOPATH
sudo mkdir -p /usr/local/var/singularity/mnt && \
mkdir -p $GOPATH/src/github.com/sylabs && \
cd $GOPATH/src/github.com/sylabs && \
wget -qO- https://github.com/sylabs/singularity/releases/download/v${SINGULARITY_VERSION}/singularity-ce-${SINGULARITY_VERSION}.tar.gz | \
tar xzv && \
cd singularity-ce-${SINGULARITY_VERSION} && \
./mconfig -p /usr/local && \
make -C builddir && \
sudo make -C builddir install
- name: Build Container
if: ${{ env.keepgoing == 'true' }}
env:
recipe: ${{ matrix.recipe }}
run: |
ls
if [ -f "${{ matrix.recipe }}" ]; then
sudo -E singularity build container.sif ${{ matrix.recipe }}
else
echo "${{ matrix.recipe }} is not found."
echo "Present working directory: $PWD"
ls
fi
- name: Generate Tag
run: |
# If triggered manually, use tag provided by user (or default)
# If triggered by release, tag with release tag
# if triggered otherwise, tag as dev
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
tag=$${{ github.event.inputs.tag }}
elif [[ "${{ github.event_name }}" == "release" ]]; then
tag=${{ github.ref }}
tag=${tag##*/}
else
tag=dev
fi
# Name the tag
echo "Tag is $tag."
echo "tag=$tag" >> $GITHUB_ENV
- name: Login and Deploy Container
if: (github.event_name != 'pull_request')
env:
keepgoing: ${{ env.keepgoing }}
run: |
if [[ "${keepgoing}" == "true" ]]; then
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io
singularity push container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${{ env.tag }}
fi