-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return buildDocker.yml to original state after using it to test doHCF…
…ILES.yml
- Loading branch information
Showing
2 changed files
with
188 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
#******************************************************************************* | ||
# doHCFILES.yml | ||
# buidDocker.yml | ||
# | ||
# Interlisp workflow to run HCFILES. HCFILES prints out PDF files for all of the | ||
# files in the Medley directory and posts them on files.interlisp.org. | ||
# | ||
# This workflow is designed to be kickjed off by the buildReleaseInclDocker | ||
# workflow running in the Medley repo, once the release has been completed successfully | ||
# Workflow to build and push a multiplatform (amd64, arm64 & arm7) Linux Docker | ||
# image for Medley. This workflow uses the latest Maiko docker image and the | ||
# latest Medley release on github. | ||
# | ||
# Copyright 2024 by Interlisp.org | ||
# This workflow contains a sentry that causes it to skip the build (as identified | ||
# by its commit SHA) if its already been done. Setting the "force" input to true | ||
# will bypass this sentry, | ||
# | ||
# Updated 2022-01-18 by Frank Halasz from on earlier buildDocker.yml | ||
# | ||
# Copyright 2022 by Interlisp.org | ||
# | ||
# ****************************************************************************** | ||
|
||
name: Run HCFILES | ||
name: 'Build/Push Docker Image' | ||
|
||
# Run this workflow on ... | ||
on: | ||
|
@@ -23,117 +27,216 @@ on: | |
options: | ||
- 'false' | ||
- 'true' | ||
force: | ||
description: "Force build even if build already successfully completed for this commit" | ||
type: choice | ||
options: | ||
- 'false' | ||
- 'true' | ||
|
||
workflow_call: | ||
outputs: | ||
successful: | ||
description: "'True' if medley docker build completed successully" | ||
value: ${{ jobs.complete.outputs.build_successful }} | ||
inputs: | ||
draft: | ||
description: "Mark this as a draft release" | ||
required: false | ||
type: string | ||
default: 'false' | ||
force: | ||
description: "Force build even if build already successfully completed for this commit" | ||
required: false | ||
type: string | ||
default: 'false' | ||
secrets: | ||
OIO_SSH_KEY: | ||
DOCKER_USERNAME: | ||
required: true | ||
MU_TOKEN: | ||
DOCKER_PASSWORD: | ||
required: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
|
||
jobs: | ||
|
||
run_HCFILES: | ||
|
||
runs-on: ubuntu-latest | ||
###################################################################################### | ||
|
||
steps: | ||
# Use sentry-action to determine if this release has already been built | ||
# based on the latest commit to the repo | ||
|
||
- name: Checkout Medley repo | ||
uses: actions/checkout@v4 | ||
sentry: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release_not_built: ${{ steps.check.outputs.release_not_built }} | ||
|
||
- name: Checkout notecards | ||
steps: | ||
# Checkout the actions for this repo owner | ||
- name: Checkout Actions | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.repository_owner }}/notecards | ||
path: ./notecards | ||
|
||
- name: Checkout loops | ||
uses: actions/checkout@v4 | ||
repository: ${{ github.repository_owner }}/.github | ||
path: ./Actions_${{ github.sha }} | ||
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }} | ||
|
||
# Check if build already run for this commit | ||
- name: Build already completed? | ||
id: check | ||
continue-on-error: true | ||
uses: ./../actions/check-sentry-action | ||
with: | ||
repository: ${{ github.repository_owner }}/loops | ||
path: ./loops | ||
tag: "docker" | ||
|
||
- name: Checkout test | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.repository_owner }}/test | ||
path: ./test | ||
###################################################################################### | ||
|
||
# | ||
# Build and push the medley docker image | ||
# | ||
|
||
- name: Cleanup .git for notecards, loops, test | ||
run: rm -rf ./notecards/.git ./loops/.git ./test/.git | ||
build_and-push: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
- name: Download Maiko | ||
needs: [sentry] | ||
if: | | ||
needs.sentry.outputs.release_not_built == 'true' | ||
|| inputs.force == 'true' | ||
steps: | ||
# Checkout latest commit | ||
- name: Checkout Medley | ||
uses: actions/checkout@v4 | ||
|
||
# Find latest release (draft or normal) | ||
# and download its assets | ||
- name: Download linux debs from latest (draft) release | ||
run: | | ||
gh release download --output /tmp/maiko.tgz \ | ||
--repo ${{ github.repository_owner }}/maiko \ | ||
--pattern '*-linux.x86_64.tgz' | ||
tar -xzf /tmp/maiko.tgz | ||
tag="" | ||
if [ "${{ inputs.draft }}" = "true" ]; | ||
then | ||
tag=$(gh release list | grep Draft | head -n 1 | awk '{ print $3 }') | ||
fi | ||
if [ -z "${tag}" ]; | ||
then | ||
tag=$(gh release list | grep Latest | head -n 1 | awk '{ print $3 }') | ||
fi | ||
mkdir -p release_debs | ||
gh release download ${tag} -D release_debs -p '*-linux-*.deb' | ||
env: | ||
GH_TOKEN: ${{ secrets.MU_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install vnc & ghostscript (ps2pdf) | ||
# Get Maiko and Medley release information from name of deb files | ||
# just downloaded from the Medley latest release | ||
- name: Get info about Miako and Medley releases | ||
id: release_info | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y tightvncserver | ||
sudo apt-get install -y ghostscript | ||
- name: Build apps.sysout | ||
regex="^medley-full-[^-]*-[^-]*-\([^_]*\)_\(.*\).deb\$" | ||
ls -1 release_debs | head -n 1 > debname.tmp | ||
medley_release="medley-$(sed -e "s/${regex}/\1/" debname.tmp)" | ||
maiko_release="maiko-$(sed -e "s/${regex}/\2/" debname.tmp)" | ||
rm -f debname.tmp | ||
echo "MEDLEY_RELEASE=${medley_release}" >> ${GITHUB_ENV} | ||
echo "MAIKO_RELEASE=${maiko_release}" >> ${GITHUB_ENV} | ||
# regex="^[^0-9]*\([^_]*\)_\([^-]*-[^-]*\)-\([^-]*\)-\([^.]*\).*\$" | ||
# Set repo env variables | ||
- name: Set repo/docker env variables | ||
id: repo_env | ||
run: | | ||
Xvnc -geometry 1280x720 :0 & | ||
export DISPLAY=":0" | ||
scripts/loadup-all.sh -apps | ||
repo_name="${GITHUB_REPOSITORY#*/}" | ||
docker_namespace="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')" | ||
docker_image="${docker_namespace}/${repo_name}" | ||
if [ "${{ inputs.draft }}" = "false" ]; | ||
then | ||
docker_tags="${docker_image}:latest,${docker_image}:${MEDLEY_RELEASE#*-}_${MAIKO_RELEASE#*-}" | ||
platforms="linux/amd64,linux/arm64" | ||
else | ||
docker_tags="${docker_image}:draft" | ||
platforms="linux/amd64" | ||
fi | ||
echo "REPO_NAME=${repo_name}" >> ${GITHUB_ENV} | ||
echo "DOCKER_NAMESPACE=${docker_namespace}" >> ${GITHUB_ENV} | ||
echo "DOCKER_IMAGE=${docker_image}" >> ${GITHUB_ENV} | ||
echo "DOCKER_TAGS=${docker_tags}" >> ${GITHUB_ENV} | ||
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_ENV} | ||
echo "PLATFORMS=${platforms}" >> ${GITHUB_ENV} | ||
#linux/amd64,linux/arm64,linux/arm/v7 | ||
# Setup the Docker Machine Emulation environment. | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
|
||
- name: Run HCFILES | ||
run: | | ||
export DISPLAY=":0" | ||
scripts/do_hcfiles.sh | ||
# Setup the Docker Buildx funtion | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Push Medley files (including created pdf files) to files.interlisp.org | ||
run: | | ||
# create a tar file of all of the directories to be pushed | ||
tarfile=/tmp/source-$$.tgz | ||
tar -c -z -f ${tarfile} --exclude=.git . | ||
# set up ssh identity | ||
eval $(ssh-agent) | ||
ssh-add - <<< "${SSH_KEY}" | ||
# set destination directory on files.interlisp.org | ||
if [ "${{ inputs.draft }}" = "true" ] | ||
then | ||
dest=/srv/oio/files/development/medley | ||
else | ||
dest=/srv/oio/files/production/medley | ||
fi | ||
# Push tar file up to files.interlisp.org | ||
batchfile=/tmp/batch-$$ | ||
echo "-put ${tarfile} ${dest}.tgz" > ${batchfile} | ||
sftp -o StrictHostKeyChecking=no -b ${batchfile} [email protected] | ||
# now tar is up, untar it and juggle backups | ||
scriptfile=/tmp/script-$$ | ||
# create script file to do the work | ||
cat > ${scriptfile} <<EOF | ||
rm -rf ${dest}.new | ||
mkdir -p ${dest}.new | ||
tar -C ${dest}.new -x -z -f ${dest}.tgz | ||
rm -f ${dest}.tgz | ||
rm -rf ${dest}.oldold | ||
if [ -e ${dest}.old ]; then mv ${dest}.old ${dest}.oldold; fi | ||
if [ -e ${dest} ]; then mv ${dest} ${dest}.old; fi | ||
mv ${dest}.new ${dest} | ||
EOF | ||
# execute the script file via ssh | ||
ssh -aTxo BatchMode=yes [email protected] /bin/sh -s < ${scriptfile} | ||
env: | ||
SSH_KEY: ${{ secrets.OIO_SSH_KEY }} | ||
# Login into DockerHub - required to store the created image | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
# 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=${{ env.BUILD_DATE }} | ||
MEDLEY_RELEASE=${{ env.MEDLEY_RELEASE }} | ||
MAIKO_RELEASE=${{ env.MAIKO_RELEASE }} | ||
REPO_OWNER=${{ github.repository_owner }} | ||
context: ./release_debs | ||
file: ./.github/workflows/Dockerfile_medley | ||
platforms: ${{ env.PLATFORMS }} | ||
# Push the result to DockerHub | ||
push: true | ||
tags: ${{ env.DOCKER_TAGS }} | ||
|
||
###################################################################################### | ||
|
||
# Use set-sentry-action to determine set the sentry that says this release has | ||
# been successfully built | ||
|
||
complete: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
build_successful: ${{ steps.output.outputs.build_successful }} | ||
|
||
needs: [sentry, build_and-push] | ||
|
||
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 }} | ||
|
||
# Set sentry | ||
- name: Set flag that build for this commit has been completed | ||
id: set | ||
uses: ./../actions/set-sentry-action | ||
with: | ||
tag: "docker" | ||
|
||
- name: Output | ||
id: output | ||
run: | | ||
echo "build_successful='true'" >> ${GITHUB_OUTPUT} | ||
###################################################################################### |
Oops, something went wrong.