-
Notifications
You must be signed in to change notification settings - Fork 28
66 lines (57 loc) · 1.97 KB
/
manual-deploy.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
name: Singularity Build (manual)
on:
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
# Do the builds on all pull requests (to test them)
pull_request: []
jobs:
build-test-containers:
runs-on: ubuntu-latest
container:
image: quay.io/singularity/singularity:v3.8.3
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: 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 }}
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.recipe }} 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