-
Notifications
You must be signed in to change notification settings - Fork 1
108 lines (94 loc) · 3.34 KB
/
build.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
name: CI Build
on:
push:
branches:
- main
- develop
tags:
- '*'
pull_request:
jobs:
envmatrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- run: echo '::set-output name=matrix::{"starenv":["root5", "root6", "root624"], "compiler":["gcc485", "gcc11"], "exclude":[{"starenv":"root624", "compiler":"gcc485"}]}'
id: set-matrix
build:
runs-on: ubuntu-latest
name: build-${{ matrix.starenv }}-${{ matrix.compiler }}
needs: envmatrix
strategy:
matrix: ${{ fromJSON(needs.envmatrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build container
uses: docker/build-push-action@v3
with:
context: .
build-args: |
starenv=${{ matrix.starenv }}
compiler=${{ matrix.compiler }}
tags: star-spack
outputs: type=docker,dest=/tmp/star-spack-${{ matrix.starenv }}-${{ matrix.compiler }}.tar
- name: Upload image artifact
uses: actions/upload-artifact@v3
with:
name: star-spack-${{ matrix.starenv }}-${{ matrix.compiler }}
path: /tmp/star-spack-${{ matrix.starenv }}-${{ matrix.compiler }}.tar
build-cleanup:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- run: .github/workflows/delete_untagged.py ${{ secrets.STAR_SPACK_TOKEN }}
test:
runs-on: ubuntu-latest
name: test-${{ matrix.starenv }}-${{ matrix.compiler }}
strategy:
matrix: ${{ fromJSON(needs.envmatrix.outputs.matrix) }}
needs: [envmatrix, build]
steps:
- name: Download image artifact
uses: actions/download-artifact@v3
with:
name: star-spack-${{ matrix.starenv }}-${{ matrix.compiler }}
path: /tmp/
- run: docker load --input /tmp/star-spack-${{ matrix.starenv }}-${{ matrix.compiler }}.tar
- run: docker run star-spack modulecmd bash avail
tag:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.envmatrix.outputs.matrix) }}
needs: [envmatrix, test]
steps:
- name: Login to GitHub container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get branch name
id: branch-name
uses: tj-actions/[email protected]
- name: Download image artifact
uses: actions/download-artifact@v3
with:
name: star-spack-${{ matrix.starenv }}-${{ matrix.compiler }}
path: /tmp/
- run: echo "REFTAG=${{ steps.branch-name.outputs.current_branch }}-${{ matrix.starenv }}-${{ matrix.compiler }}" >> $GITHUB_ENV
- run: docker load --input /tmp/star-spack-${{ matrix.starenv }}-${{ matrix.compiler }}.tar
- run: docker tag star-spack ghcr.io/star-bnl/star-spack:${REFTAG}
- run: docker push ghcr.io/star-bnl/star-spack:${REFTAG}