-
-
Notifications
You must be signed in to change notification settings - Fork 1
194 lines (170 loc) · 6.96 KB
/
buildMedleyDocker.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# buildDocker.yml
#
# Workflow to build and push a multiplatform Docker image for the Medley that runs
# on online.interlisp.org.
#
# This workflow uses the latest Medley docker image and the latest Interlisp/online
# release on github.
#
# 2022-01-19 by Frank Halasz based on Medley buildDocker.yml
#
#
# Copyright: 2022 by Interlisp.org
#
#
name: 'Build/Push Online-Medley Docker Image'
# Run this workflow on ...
on:
workflow_dispatch:
inputs:
platform:
type: choice
options:
- linux/amd64
- linux/arm64
workflow_call:
secrets:
CCRYPT_KEY:
required: true
inputs:
platform:
description: "linux/amd64 or linux/arm64"
type: string
default: 'linux/amd64'
required: false
jobs:
# Build and push the docker image
build_and-push:
runs-on: ubuntu-latest
steps:
# Checkout the actions for this repo_owner
- name: Checkout Actions
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}
# Fetch cached LFS files
- name: Cache LFS files
id: cache-lfs
uses: actions/cache@v4
with:
path: |
docker_medley/filebrowser/filebrowser
docker_medley/gh/gh_2.14.7_linux_amd64.deb
docker_medley/gh/gh_2.14.7_linux_arm64.deb
key: ${{ runner.os }}-lfs-v1
# Save cached files away - if any
- name: Save LFS files
if: steps.cache-lfs.outputs.cache-hit == 'true'
run: mv docker_medley ../save_docker_medley
# Checkout latest commit
- name: Checkout Online code
uses: actions/checkout@v4
with:
lfs: ${{ steps.cache-lfs.outputs.cache-hit != 'true' }}
- name: Checkout lfs files
if: steps.cache-lfs.outputs.cache-hit != 'true'
run: git lfs checkout
# Restore cached files from save
- name: Restore LFS files
if: steps.cache-lfs.outputs.cache-hit == 'true'
run: |
mv ../save_docker_medley/filebrowser/filebrowser docker_medley/filebrowser/filebrowser
rm -rf ../save_docker_medley
# Setup release tag
- name: Setup Release Tag
id: tag
uses: ./../actions/release-tag-action
# Decrypt the sftp keys
- name: Decrypt sftp keys
run: |
sudo apt-get install -y ccrypt
pushd docker_medley/sftp >/dev/null
cat <sftp_keys.tar.cpt | ccdecrypt -K ${{ secrets.CCRYPT_KEY }} | /usr/bin/tar x
popd >/dev/null
# Get release information about latest Medley Docker Image
- name: Get info from latest Medley image
id: release_info
run: |
DOCKER_NAMESPACE=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "docker_namespace=${DOCKER_NAMESPACE}" >> $GITHUB_OUTPUT
docker pull ${DOCKER_NAMESPACE}/medley:latest
RELEASE_INFO=$(docker run --entrypoint /bin/bash ${DOCKER_NAMESPACE}/medley:latest -c "echo \${MAIKO_RELEASE}::::\${MEDLEY_RELEASE}")
MAIKO_RELEASE=${RELEASE_INFO%::::*}
MEDLEY_RELEASE=${RELEASE_INFO#*::::}
echo "MAIKO_RELEASE=${MAIKO_RELEASE}" >> ${GITHUB_ENV}
echo "maiko_release=${MAIKO_RELEASE}" >> ${GITHUB_OUTPUT}
echo "MEDLEY_RELEASE=${MEDLEY_RELEASE}" >> ${GITHUB_ENV}
echo "medley_release=${MEDLEY_RELEASE}" >> ${GITHUB_OUTPUT}
# Checkout the latest Notecards commit
- name: Checkout Notecards
uses: actions/checkout@v4
with:
repository: "${{ github.repository_owner }}/notecards"
path: "./docker_medley/notecards"
# Compute release tag for notecards
- name: Notecards Release Tag
id: nc_release_info
run: |
cd ./docker_medley/notecards
COMMIT_SHORTREF=$(git rev-parse --short=8 HEAD)
COMMIT_DATE=$(git show -s --date=format:'%y%m%d' --format=%cd ${COMMIT_SHORTREF})
NC_RELEASE_TAG=notecards-${COMMIT_DATE}-${COMMIT_SHORTREF}
#
echo "NC_RELEASE_TAG=${NC_RELEASE_TAG}" >> ${GITHUB_ENV}
echo "nc_release_tag=${NC_RELEASE_TAG}" >> ${GITHUB_OUTPUT}
# Setup docker environment variables
- name: Setup Docker Environment Variables
id: docker_env
run: |
DOCKER_REGISTRY="ghcr.io/"
DOCKER_NAMESPACE=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "docker_namespace=${DOCKER_NAMESPACE}" >> ${GITHUB_OUTPUT}
DOCKER_REPO=${DOCKER_REGISTRY}${DOCKER_NAMESPACE}/${{ steps.tag.outputs.repo_name }}-medley
DOCKER_TAGS="${DOCKER_REPO}:development,${DOCKER_REPO}:${RELEASE_TAG#*-}_${MEDLEY_RELEASE#*-}_${MAIKO_RELEASE#*-}"
echo "build_time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_OUTPUT}
echo "docker_tags=${DOCKER_TAGS}" >> ${GITHUB_OUTPUT}
# Setup the Docker Machine Emulation environment.
- name: Set up QEMU
if: ${{ inputs.platform == 'linux/arm64' }}
uses: docker/setup-qemu-action@master
with:
platforms: linux/arm64
# Setup the Docker Buildx funtion
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
# Login to ghcr.io
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Set up platform variable so it can be used by Docker build
- name: Strip the linux/ from the platform input
id: platform_var
run: |
echo "platform=$(echo "${{ inputs.platform }}" | sed s-linux/--)" >> ${GITHUB_OUTPUT}
# Do the Docker Build using the Dockerfile in the repository
# checked out and the release tars just downloaded.
# Push the result to Docker Hub
- name: Build Docker Image for Push to Docker Hub
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
build-args: |
BUILD_DATE=${{ steps.docker_env.outputs.build_time }}
RELEASE_TAG=${{ steps.tag.outputs.release_tag }}
MAIKO_RELEASE=${{ steps.release_info.outputs.maiko_release }}
MEDLEY_RELEASE=${{ steps.release_info.outputs.medley_release }}
DOCKER_NAMESPACE=${{ steps.release_info.outputs.docker_namespace }}
REPO_OWNER=${{ github.repository_owner }}
NOTECARDS_RELEASE=${{ steps.nc_release_info.outputs.nc_release_tag }}
PLATFORM=${{ steps.platform_var.outputs.platform }}
context: ./docker_medley
file: ./docker_medley/Dockerfile_medley
platforms: ${{ inputs.platform }}
push: true
tags: ${{ steps.docker_env.outputs.docker_tags }}