-
Notifications
You must be signed in to change notification settings - Fork 28
83 lines (73 loc) · 2.5 KB
/
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
name: Singularity Build (docker)
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) }}
singularity_version:
- '3.8.1'
container:
image: quay.io/singularity/singularity:v${{ matrix.singularity_version }}
options: --privileged
name: Check ${{ matrix.changed_file }}
steps:
- name: Check out code for the container builds
uses: actions/checkout@v2
- 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: 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