-
Notifications
You must be signed in to change notification settings - Fork 18
78 lines (65 loc) · 2.51 KB
/
deploy-ghcr.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
name: Build and deploy as Apptainer container image to GitHub Container Registry
on:
pull_request: []
push:
branches:
- main
release:
types: [ published ]
jobs:
build-deploy-container:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -leo pipefail {0}
permissions:
packages:
write
strategy:
matrix:
deffiles: [[Singularity, latest]]
env:
container: nectarchain
registry: ghcr.io
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Setup Apptainer
uses: eWaterCycle/setup-apptainer@v2
with:
apptainer-version: 1.1.7
- name: Build ${{ env.container }} container
run: |
echo "Preparing to build ${{ env.container }} from ${{ matrix.deffiles[0] }}"
if [ ! -f "${{ matrix.deffiles[0]}}" ]; then
echo "Singularity definition file ${{ matrix.deffiles[0] }} does not exist"
exit 1
fi
apptainer build ${{ env.container }}.sif ${{ matrix.deffiles[0] }}
ls -lh
- name: Login to GitHub Container Registry
# Don't log into registry on pull request.
if: github.event_name != 'pull_request'
run: |
echo ${{ github.token }} | apptainer remote login --username ${{ github.actor }} --password-stdin oras://${{ env.registry }}
- name: Deploy ${{ env.container }} container ${{ github.ref_name }}
# Assign the release tag to container on release
if: github.event_name == 'release'
run: |
fullversionname=${{ github.ref_name }}
# Remove the leading "v" character
versionname=${fullversionname:1}
apptainer push ${{ env.container }}.sif oras://${{ env.registry }}/${{ github.repository }}:${versionname}
- name: Deploy ${{ env.container }} container ${{ matrix.deffiles[1] }}
# Otherwise, the container tag is "latest" by default.
# Don't push the container on a pull request.
if: ${{ (github.event_name != 'release') && (github.event_name != 'pull_request') }}
run: |
apptainer push ${{ env.container }}.sif oras://${{ env.registry }}/${{ github.repository }}:${{ matrix.deffiles[1] }}
- name: Post Login to GitHub Container Registry
# Don't log out from registry on pull request.
if: github.event_name != 'pull_request'
run: |
apptainer remote logout oras://${{ env.registry }}