Docker #91
Workflow file for this run
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: Docker | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/docker.yml' | |
| - 'dependencies/current/**' | |
| - 'dependencies/testing/**' | |
| - 'docker/dependencies/**' | |
| env: | |
| REGISTRY: ghcr.io | |
| PROJECT_NAMESPACE: 4c-multiphysics | |
| IMAGE_SUFFIX: dependencies | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check-if-build-dependencies-is-required: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' | |
| outputs: | |
| dependencies_hash: ${{ steps.check-docker-build-required.outputs.dependencies_hash }} | |
| build_docker_image: ${{ steps.check-docker-build-required.outputs.build_docker_image }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - id: check-docker-build-required | |
| uses: ./.github/actions/check_docker_build_required | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| image-name: ${{ env.REGISTRY }}/${{ env.PROJECT_NAMESPACE }}/4c-dependencies-ubuntu24.04 | |
| build-dependencies: | |
| runs-on: ubuntu-latest | |
| # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| # | |
| needs: check-if-build-dependencies-is-required | |
| if: ${{ github.event_name == 'workflow_dispatch' && needs.check-if-build-dependencies-is-required.outputs.build_docker_image | |
| == 'true' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Build and push image | |
| uses: ./.github/actions/build_dependencies | |
| with: | |
| docker-file: docker/dependencies/Dockerfile | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| image-name: ${{ env.REGISTRY }}/${{ env.PROJECT_NAMESPACE }}/4c-dependencies-ubuntu24.04 | |
| dependencies-hash: ${{ needs.check-if-build-dependencies-is-required.outputs.dependencies_hash | |
| }} | |
| base-image: "ubuntu:24.04" | |
| build-dependencies-oldest-supported: | |
| runs-on: ubuntu-latest | |
| # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| # | |
| needs: check-if-build-dependencies-is-required | |
| if: ${{ github.event_name == 'workflow_dispatch' && needs.check-if-build-dependencies-is-required.outputs.build_docker_image | |
| == 'true' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Build and push image | |
| uses: ./.github/actions/build_dependencies | |
| with: | |
| docker-file: docker/oldest_supported/Dockerfile | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| image-name: ${{ env.REGISTRY }}/${{ env.PROJECT_NAMESPACE }}/4c-dependencies-ubuntu24.04-oldest-supported | |
| dependencies-hash: ${{ needs.check-if-build-dependencies-is-required.outputs.dependencies_hash | |
| }} | |
| base-image: "ubuntu:24.04" | |
| tag-images-as-main: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.ref == 'refs/heads/main' && github.repository == '4C-multiphysics/4C' }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - id: compute-dependencies-hash | |
| uses: ./.github/actions/compute-and-check-dependencies-hash | |
| with: | |
| skip-check: 'true' | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull current Ubuntu 24.04 dependencies image and tag it with main | |
| run: | | |
| IMAGE_NAME="${{ env.REGISTRY }}/${{ env.PROJECT_NAMESPACE }}/4c-dependencies-ubuntu24.04" | |
| docker pull $IMAGE_NAME:${{ steps.compute-dependencies-hash.outputs.computed_dependencies_hash }} | |
| docker image tag $IMAGE_NAME:${{ steps.compute-dependencies-hash.outputs.computed_dependencies_hash }} $IMAGE_NAME:main | |
| docker push $IMAGE_NAME:main |