trigger-container-build #60
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: Build & Deploy Docker Containers | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: [trigger-container-build] | |
jobs: | |
build-test-deploy-docker: | |
runs-on: ubuntu-latest | |
env: # default settings (overwritten by repository_dispatch) | |
registry: ghcr.io | |
MATLAB_VERSION: R2024b | |
AGREE_TO_MATLAB_RUNTIME_LICENSE: "yes" | |
SPM_RELEASE: "24.10" | |
SPM_REVISION: alpha16 | |
strategy: | |
fail-fast: false | |
matrix: | |
recipe: ["matlab", "octave"] | |
name: Build ${{ matrix.recipe }} | |
steps: | |
- name: Set environment variables for repository_dispatch | |
if: ${{ github.event_name == 'repository_dispatch' }} | |
run: | | |
echo "MATLAB_VERSION=${{ github.event.client_payload.matlab_version }}" >> $GITHUB_ENV | |
echo "AGREE_TO_MATLAB_RUNTIME_LICENSE=${{ github.event.client_payload.agree_to_matlab_runtime_license }}" >> $GITHUB_ENV | |
echo "SPM_RELEASE=${{ github.event.client_payload.spm_release }}" >> $GITHUB_ENV | |
echo "SPM_REVISION=${{ github.event.client_payload.spm_revision }}" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Create derived environment variables | |
run: | | |
echo "SPM_TAG=${SPM_RELEASE}${SPM_REVISION:+.${SPM_REVISION}}" >> $GITHUB_ENV | |
echo "SPM_VERSION=${SPM_RELEASE:0:2}" >> $GITHUB_ENV | |
- name: Build Container | |
run: | | |
tag=docker-${{ matrix.recipe }}-${{ env.SPM_TAG }} | |
latest_tag=docker-${{ matrix.recipe }}-latest | |
docker build \ | |
--build-arg MATLAB_VERSION=${{ env.MATLAB_VERSION }} \ | |
--build-arg AGREE_TO_MATLAB_RUNTIME_LICENSE=${{ env.AGREE_TO_MATLAB_RUNTIME_LICENSE }} \ | |
--build-arg SPM_VERSION=${{ env.SPM_VERSION }} \ | |
--build-arg SPM_RELEASE=${{ env.SPM_RELEASE }} \ | |
--build-arg SPM_REVISION=${{ env.SPM_REVISION }} \ | |
-f ${{ matrix.recipe }}\Dockerfile \ | |
-t ${{ env.registry }}/${GITHUB_REPOSITORY}:${tag} \ | |
-t ${{ env.registry }}/${GITHUB_REPOSITORY}:${latest_tag} . | |
- name: Log in to GitHub Container Registry | |
if: ${{ github.repository_owner }} == 'spm' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.registry }} | |
username: ${{ secrets.GHCR_USERNAME }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Deploy Container | |
if: ${{ github.repository_owner }} == 'spm' | |
run: docker push ${{ env.registry }}/${GITHUB_REPOSITORY} --all-tags | |
- name: Trigger workflow in spm-docker | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
event-type: trigger-singularity-build | |
client-payload: |- | |
{ | |
"spm_tag": "${{ env.SPM_TAG }}", | |
} |