Generate Container Guts #825
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
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", "ubuntu:24.04", | |
"debian:12", "debian:11", "debian:10", "debian:9", | |
"centos:6", "centos:7", "centos:8", | |
"rockylinux:8.6", "rockylinux:9.0", | |
"fedora:34", "fedora:35", "fedora:36", "fedora:37", | |
"fedora:38", "fedora:39", "fedora:40", | |
"alpine:3.7", "alpine:3.8", "alpine:3.9", "alpine:3.10", | |
"alpine:3.11", "alpine:3.12", "alpine:3.13", "alpine:3.14", | |
"alpine:3.15", "alpine:3.16", "alpine:3.17", "alpine:3.18", | |
"alpine:3.19", "alpine:3.20", | |
"busybox:1.25", "busybox:1.26", "busybox:1.27", "busybox:1.28", | |
"busybox:1.29", "busybox:1.30", "busybox:1.31", "busybox:1.32", | |
"busybox:1.33", "busybox:1.34"] | |
name: Generate Matrix | |
steps: | |
- name: Install Guts | |
run: pip install --break-system-packages 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 |