-
Notifications
You must be signed in to change notification settings - Fork 28
114 lines (102 loc) · 3.57 KB
/
native-install.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
name: Singularity Build (native)
on:
push:
# Edit the branches here if you want to change deploy behavior
branches:
- main
- master
# Do the builds on all pull requests (to test them)
pull_request: []
jobs:
changes:
name: "Changed Singularity Recipes"
runs-on: ubuntu-latest
outputs:
changed_file: ${{ steps.files.outputs.added_modified }}
steps:
- id: files
uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42
with:
format: 'json'
build-test-containers:
needs:
- changes
runs-on: ubuntu-latest
strategy:
# Keep going on other deployments if anything bloops
fail-fast: false
matrix:
changed_file: ${{ fromJson(needs.changes.outputs.changed_file) }}
name: Check ${{ matrix.changed_file }}
steps:
- name: Continue if Singularity Recipe
run: |
# Continue if we have a changed Singularity recipe
if [[ "${{ matrix.changed_file }}" = *Singularity* ]]; 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: Check out code for the container build
if: ${{ env.keepgoing == 'true' }}
uses: actions/checkout@v2
- name: Build Container
if: ${{ env.keepgoing == 'true' }}
env:
recipe: ${{ matrix.changed_file }}
run: |
ls
if [ -f "${{ matrix.changed_file }}" ]; then
sudo -E singularity build container.sif ${{ matrix.changed_file }}
tag=$(echo "${recipe/Singularity\./}")
if [ "$tag" == "Singularity" ]; then
tag=latest
fi
# Build the container and name by tag
echo "Tag is $tag."
echo "tag=$tag" >> $GITHUB_ENV
else
echo "${{ matrix.changed_file }} is not found."
echo "Present working directory: $PWD"
ls
fi
- 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}:${tag}
fi