feat: Add ot-sim/pandapower image #196
This file contains hidden or 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: image-build | |
| # Controls when the workflow will run | |
| on: | |
| # Trigger on push or pull request to main branch | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| # Allow manual run from Actions tab | |
| workflow_dispatch: | |
| # Scheduled run every Wednesday at 11:11 UTC | |
| schedule: | |
| - cron: "11 11 * * WED" | |
| jobs: | |
| # Job: Build images using the phenix image builder | |
| build-images: | |
| strategy: | |
| matrix: | |
| build: | |
| [ | |
| bookworm, | |
| kali, | |
| kali-harmonie, | |
| jammy, | |
| noble, | |
| bennu, | |
| docker-hello-world, | |
| ntp, | |
| vyos, | |
| minirouter, | |
| ubuntu-soaptools, | |
| ot-sim | |
| ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout repository code | |
| - uses: actions/checkout@v4 | |
| # Create slug var for branch ref suitiable for tags | |
| - uses: rlespinasse/github-slug-action@v5.2.0 | |
| # Install oras CLI for pushing images to OCI registries | |
| - uses: oras-project/setup-oras@v1 | |
| - uses: docker/setup-docker-action@v4 | |
| - uses: docker/setup-compose-action@v1 | |
| - name: install dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y qemu-utils guestfs-tools | |
| # Pull docker containers | |
| - name: pull docker containers | |
| run: | | |
| docker pull ghcr.io/sandialabs/sceptre-phenix/phenix:main | |
| docker pull ghcr.io/sandialabs/sceptre-phenix/minimega:main | |
| docker tag ghcr.io/sandialabs/sceptre-phenix/phenix:main phenix:latest | |
| docker tag ghcr.io/sandialabs/sceptre-phenix/minimega:main minimega:latest | |
| # Start docker containers | |
| - name: wget docker-compose.yml | |
| uses: wei/wget@v1 | |
| with: | |
| args: https://raw.githubusercontent.com/sandialabs/sceptre-phenix/refs/heads/main/docker/docker-compose.yml | |
| - name: start docker containers | |
| run: | | |
| sed -i 's/\.\/tmp/\/tmp/g' docker-compose.yml | |
| sed -i '\|/tmp/phenix|a\ - ${{ github.workspace }}:/${{ github.workspace }}\n working_dir: ${{ github.workspace }}' docker-compose.yml | |
| docker compose -f docker-compose.yml up -d phenix | |
| echo "Waiting for services to start..." | |
| sleep 5 | |
| # Extract miniccc and minirouter binaries | |
| - name: get miniccc and minirouter | |
| run: | | |
| docker cp minimega:/opt/minimega/bin/miniccc ${{ github.workspace }} | |
| docker cp minimega:/opt/minimega/bin/minirouter ${{ github.workspace }} | |
| # Remove unneeded tools to make more build space | |
| - name: free disk space | |
| uses: jlumbroso/free-disk-space@v1.3.1 | |
| with: | |
| # skip the remove large-packages step because it takes a while | |
| large-packages: false | |
| # Build the non-vyos images using phenix | |
| - name: ${{ matrix.build }} image build | |
| if: ${{ matrix.build != 'vyos' }} | |
| run: make ${{ matrix.build }} | |
| # Build the vyos image using custom build script | |
| # Using /mnt for more temp space for injecting miniccc | |
| - name: ${{ matrix.build }} image build | |
| if: ${{ matrix.build == 'vyos' }} | |
| shell: bash | |
| run: | | |
| sudo modprobe nbd | |
| export VYOSTMP=/mnt/vyostmp | |
| sudo -E make ${{ matrix.build }} | |
| # Publish the built image to GitHub Container Registry using oras | |
| - name: publish package with oras | |
| # Only push package if on the default branch (e.g., main) | |
| # or if manually triggered on a different branch so maintainers can manually push images | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.event_name == 'workflow_dispatch' | |
| shell: bash | |
| run: | | |
| oras login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io | |
| oras push "ghcr.io/${{ github.repository }}/${{ matrix.build }}.qc2:${GITHUB_SHA:0:7}" ${{ matrix.build }}.qc2 | |
| # tag with branch name | |
| oras tag "ghcr.io/${{ github.repository }}/${{ matrix.build }}.qc2:${GITHUB_SHA:0:7}" "${GITHUB_REF_SLUG}" | |
| # Job: Tag images after successful builds | |
| tag-images: | |
| strategy: | |
| matrix: | |
| build: | |
| [ | |
| bookworm, | |
| kali, | |
| kali-harmonie, | |
| jammy, | |
| noble, | |
| bennu, | |
| docker-hello-world, | |
| ntp, | |
| vyos, | |
| minirouter, | |
| ubuntu-soaptools, | |
| ot-sim | |
| ] | |
| # Only run on main branch for scheduled or manual workflow_dispatch events | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') | |
| needs: build-images | |
| runs-on: ubuntu-latest | |
| outputs: | |
| date: ${{ steps.date.outputs.date }} | |
| steps: | |
| # Get current date for tagging | |
| - name: Get current date | |
| id: date | |
| run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | |
| # Install oras CLI | |
| - uses: oras-project/setup-oras@v1 | |
| # Tag images in the registry with 'latest' and date-based tags | |
| - name: tag images with date and latest | |
| run: | | |
| oras version | |
| oras login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io | |
| oras tag ghcr.io/${{ github.repository }}/${{ matrix.build }}.qc2:${GITHUB_SHA:0:7} latest ${{ steps.date.outputs.date }} | |
| # Job: Create release successful build | |
| release: | |
| # Only run on main branch for scheduled or manual workflow_dispatch events | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') | |
| needs: tag-images | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Create a GitHub release with notes and usage instructions | |
| - name: create release | |
| uses: ncipollo/release-action@v1.15.0 | |
| with: | |
| name: release-${{ needs.tag-images.outputs.date }} | |
| body: | | |
| Images can be downloaded from the registry using the oras client: https://oras.land/docs/installation | |
| e.g.: | |
| ```bash | |
| oras pull ghcr.io/${{ github.repository }}/bennu.qc2:latest | |
| ``` | |
| You can view the available image builds from the [Package List](https://github.com/orgs/${{ github.repository_owner }}/packages?repo_name=${{ github.event.repository.name }}) | |
| tag: release-${{ needs.tag-images.outputs.date }} | |
| commit: main | |
| generateReleaseNotes: true | |
| makeLatest: true |