-
Notifications
You must be signed in to change notification settings - Fork 1
166 lines (146 loc) · 5.6 KB
/
build-publish-containers.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: Build and publish container images
on:
pull_request:
workflow_dispatch:
inputs:
upstream_version:
type: string
description: Which version should be build?
push:
schedule:
# rebuild image every Monday morning
- cron: '43 3 * * 1'
jobs:
build_publish:
name: Build/publish containers
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
tag:
- azure-pipelines-azureagent
- azure-pipelines-jupyterhub
- azure-pipelines-rocky8
fail-fast: false
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Fix image date tag
run: |
echo IMAGE_TAG=$(date +"%Y%m%d") >> $GITHUB_ENV
- name: Check if we should publish
if: >-
(github.event_name == 'push' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch') &&
github.ref_name == 'main'
run: |
echo PUBLISH_IMAGES=1 >> $GITHUB_ENV
- name: Determine latest release of VSTS Agent
if: matrix.tag == 'azure-pipelines-azureagent'
id: getvstsagentlatest
run: |
release=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/microsoft/azure-pipelines-agent/releases/latest | jq -r .name)
echo "Building release $release"
echo "RELEASE=${release:1}" >> $GITHUB_ENV
- name: Fetch vsc-config
if: matrix.tag == 'azure-pipelines-jupyterhub'
uses: actions/checkout@v4
with:
repository: vub-hpc/vsc-config
token: ${{ secrets.GH_PAT_VSC_CONFIG }}
path: azure-pipelines-jupyterhub/vsc-config
- name: Build Image
uses: redhat-actions/[email protected]
id: build-image
with:
tags: latest ${{ github.sha }} ${{ env.IMAGE_TAG }} ${{env.RELEASE}}
image: ${{ matrix.tag }}
context: ${{ matrix.tag }}
build-args: |
operator_name=${{ secrets.JH_USERNAME }}
operator_uid=${{ secrets.JH_UID }}
az_ag_release=${{ env.RELEASE }}
dockerfiles: |
./${{ matrix.tag }}/Dockerfile
- name: Print image name and tags
run: echo "Image ${{ steps.build-image.outputs.image }} build with tags ${{ steps.build-image.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
- name: Publish image on ghcr.io
id: push-to-ghcr
if: env.PUBLISH_IMAGES
uses: redhat-actions/[email protected]
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Print image url
if: env.PUBLISH_IMAGES
run: echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}" >> $GITHUB_STEP_SUMMARY
build_publish_ondemand:
name: Build/publish ondemand container
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check if we should publish
if: >-
(github.event_name == 'push' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch') &&
github.ref_name == 'main'
run: |
echo PUBLISH_IMAGES=1 >> $GITHUB_ENV
- name: Set a tag based on the date
run: |
IMAGE_TAG=$(date +"%Y%m%d")
echo IMAGE_TAG=$IMAGE_TAG >> $GITHUB_ENV
echo "Image tag is $IMAGE_TAG"
- name: Determine latest release of ondemand
id: getlatestrelease
run: |
release=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/OSC/ondemand/releases/latest | jq -r .name)
echo "Building release $release"
echo "RELEASE=${release}" >> $GITHUB_ENV
- name: Check the version specified manually
if: ${{ inputs.upstream_version }}
shell: bash
run: |
release=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/OSC/ondemand/releases/tags/${{ inputs.upstream_version }} | jq -e -r .name)
echo "Building release $release"
echo "RELEASE=${release}" >> $GITHUB_ENV
- name: Check out the repo
uses: actions/checkout@v4
with:
repository: 'OSC/ondemand'
ref: '${{ env.RELEASE }}'
path: 'ondemand'
- name: Build Image
uses: redhat-actions/buildah-build@v2
id: build-image
with:
tags: latest ${{ env.IMAGE_TAG }} ${{ env.RELEASE }}
image: ondemand
containerfiles: ondemand/Dockerfile
context: ondemand
build-args: |
VERSION=${{ env.RELEASE }}
- name: Print image name and tags
run: echo "Image ${{ steps.build-image.outputs.image }} build with tags ${{ steps.build-image.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
- name: Publish image on ghcr.io
id: push-to-ghcr
if: env.PUBLISH_IMAGES
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Print image url
if: env.PUBLISH_IMAGES
run: echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}" >> $GITHUB_STEP_SUMMARY