Skip to content

Generate Container Guts #652

Generate Container Guts

Generate Container Guts #652

Workflow file for this run

name: Generate Container Guts
on:
pull_request: []
push:
branches:
- main
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
inputs:
docker_uri:
description: 'Docker identifier to generate recipe for'
required: true
jobs:
generate-recipe:
if: (inputs.docker_uri != '')
runs-on: ubuntu-latest
name: ${{ inputs.docker_uri }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Guts for ${{ inputs.docker_uri }}
uses: singularityhub/guts/action/manifest@main
with:
image: ${{ inputs.docker_uri }}
generate-recipes:
if: (inputs.docker_uri == '')
runs-on: ubuntu-latest
strategy:
fail-fast: false
# Here is our matrix of base images to generate
matrix:
image: ["ubuntu:18.04", "ubuntu:20.04", "ubuntu:22.04",
"debian:11", "debian:10", "debian:9",
"centos:6", "centos:7", "centos:8",
"rockylinux:8.6", "rockylinux:9.0",
"fedora:34", "fedora:35", "fedora:36",
"alpine:3.7", "alpine:3.8", "alpine:3.9", "alpine:3.10", "alpine:3.11",
"busybox:1.23", "busybox:1.24", "busybox:1.25", "busybox:1.26", "busybox:1.27"]
name: Generate Matrix
steps:
- name: Install Guts
run: pip install git+https://github.com/singularityhub/guts@main
- name: Guts for ${{ matrix.image }}
uses: singularityhub/guts/action/manifest@main
id: guts
with:
image: ${{ matrix.image }}
include: paths fs
outdir: /tmp
- name: View Output
env:
outfile: ${{ steps.guts.outputs.outfile }}
run: |
echo $outfile
cat ${outfile}
- name: Prepare Dest Directory
env:
outfile: ${{ steps.guts.outputs.outfile }}
run: |
root=$(python -c "print('${outfile}'.split('/')[2])")
echo ${root}
echo "root=${root}" >> $GITHUB_ENV
- name: Checkout Repository
if: (github.event_name != 'pull_request')
uses: actions/checkout@v4
- name: Push new result
if: (github.event_name != 'pull_request')
env:
dest: ${{ env.outdir }}/${{ matrix.image }}.json
outfile: ${{ steps.guts.outputs.outfile }}
root: ${{ env.root }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git config --global user.name "github-actions"
git config --global user.email "github-actions@users.noreply.github.com"
git config --global pull.rebase true
git checkout main
git branch
ls
cp -R /tmp/${root} .
git add ${root}/*
ls
ls ${root}
if git diff-index --quiet HEAD --; then
printf "No changes\n"
else
printf "Changes\n"
today=$(date '+%Y-%m-%d')
git commit -a -m "Automated deployment to add/update ${outdir}"
while ! git push origin main
do
echo "Trying again..."
sleep $[ ( $RANDOM % 10 ) + 1 ]s
git pull origin main
done
fi