-
Notifications
You must be signed in to change notification settings - Fork 43
166 lines (153 loc) · 5.78 KB
/
container_upload.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Push containers to registries
on:
pull_request_target:
types: [closed]
paths:
- 'container/*/*.yml'
jobs:
setup:
runs-on: ubuntu-latest
strategy:
fail-fast: false
outputs:
matrix: ${{ steps.export-directories.outputs.matrix }}
any_changed: ${{ steps.download-changed-directories.outputs.found_artifact }}
if: github.event.pull_request.merged == true
steps:
- name: Download changed directories
id: download-changed-directories
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: container_build.yml
name: 'changed_directories_${{ github.event.pull_request.head.sha }}'
name_is_regexp: true
path: /tmp
if_no_artifact_found: warn
- name: Export changed directories
id: export-directories
run: cat /tmp/changed_directories_${{ github.event.pull_request.head.sha }}/changed_directories.json >> "$GITHUB_OUTPUT"
push_docker_containers:
needs: setup
if: needs.setup.outputs.any_changed == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
permissions:
contents: read
packages: write
steps:
- name: Checkout pull request branch
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup up docker buildx
uses: docker/setup-buildx-action@v2
- name: Get basename
id: context_basename
run: echo "basename=$(basename ${{ matrix.context }})" >> "$GITHUB_OUTPUT"
- name: Log in to ghcr.io with docker
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{github.repository_owner}}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to quay.io with docker
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ vars.QUAYIO_USERNAME }}
password: ${{ secrets.QUAYIO_TOKEN }}
- name: Log in to docker.io with docker
uses: docker/login-action@v2
with:
registry: docker.io
username: ${{ vars.DOCKERIO_USERNAME }}
password: ${{ secrets.DOCKERIO_TOKEN }}
- name: Build and push docker containers
uses: docker/build-push-action@v4
with:
context: ${{ matrix.context }}
file: .github/docker.df
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ steps.context_basename.outputs.basename }}_docker:latest
quay.io/${{ vars.QUAYIO_USERNAME }}/${{ steps.context_basename.outputs.basename }}_docker:latest
docker.io/${{ vars.DOCKERIO_USERNAME }}/${{ steps.context_basename.outputs.basename }}_docker:latest
# push_apptainer_containers:
# needs: setup
# if: needs.setup.outputs.any_changed == 'true'
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
# permissions:
# contents: read
# packages: write
#
# steps:
# - name: Checkout pull request branch
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
#
# - name: Setup micromamba
# uses: mamba-org/setup-micromamba@v1
# with:
# environment-name: containers
# create-args: apptainer
# generate-run-shell: true
#
# - name: Get basename
# id: context_basename
# run: echo "basename=$(basename ${{ matrix.context }})" >> "$GITHUB_OUTPUT"
#
# - name: Build apptainer containers
# shell: micromamba-shell {0}
# run: |
# pushd ${{ matrix.context}}; \
# apptainer build /tmp/${{ steps.context_basename.outputs.basename }}_apptainer.sif ${{ github.workspace }}/.github/apptainer.def; \
# popd
#
# - name: Log in to ghcr.io with apptainer
# shell: micromamba-shell {0}
# run: |
# apptainer remote login --username ${{ github.repository_owner }} \
# --password ${{ secrets.GITHUB_TOKEN }} \
# docker://ghcr.io/${{ github.repository_owner }}
#
# - name: Push apptainer containers to ghcr.io
# shell: micromamba-shell {0}
# run: |
# apptainer push \
# /tmp/${{ steps.context_basename.outputs.basename }}_apptainer.sif \
# oras://ghcr.io/${{ github.repository_owner }}/${{ steps.context_basename.outputs.basename }}_apptainer:latest
#
# - name: Log in to quay.io with apptainer
# shell: micromamba-shell {0}
# run: |
# apptainer remote login --username ${{ vars.QUAYIO_USERNAME }} \
# --password ${{ secrets.QUAYIO_TOKEN }} \
# docker://quay.io/${{ vars.QUAYIO_USERNAME }}
#
# - name: Push apptainer containers to quay.io
# shell: micromamba-shell {0}
# run: |
# apptainer push \
# /tmp/${{ steps.context_basename.outputs.basename }}_apptainer.sif \
# oras://quay.io/${{ vars.QUAYIO_USERNAME }}/${{ steps.context_basename.outputs.basename }}_apptainer:latest
#
# - name: Log in to docker.io with apptainer
# shell: micromamba-shell {0}
# run: |
# apptainer remote login --username ${{ vars.DOCKERIO_USERNAME }} \
# --password ${{ secrets.DOCKERIO_TOKEN }} \
# docker://docker.io
#
# - name: Push apptainer containers to docker.io
# shell: micromamba-shell {0}
# run: |
# apptainer push \
# /tmp/${{ steps.context_basename.outputs.basename }}_apptainer.sif \
# oras://docker.io/${{ vars.DOCKERIO_USERNAME }}/${{ steps.context_basename.outputs.basename }}_apptainer:latest