|
46 | 46 | required: true |
47 | 47 |
|
48 | 48 | jobs: |
49 | | - docker_build: |
50 | | - name: "Build the ${{ inputs.target }} container" |
51 | | - strategy: |
52 | | - fail-fast: false |
53 | | - runs-on: [self-hosted, "${{ inputs.os }}"] |
| 49 | + docker_build_linux: |
| 50 | + name: Build the ${{ inputs.target }} container (Linux) |
| 51 | + if: inputs.os == 'Linux' |
| 52 | + runs-on: [self-hosted, Linux] |
| 53 | + container: ubuntu:latest |
54 | 54 | steps: |
55 | 55 | - name: Pre-cleanup |
56 | 56 | if: always() |
| 57 | + run: find . -delete |
| 58 | + |
| 59 | + - name: Set up Docker |
57 | 60 | run: | |
58 | | - rm -rf ${{ runner.temp }}/digests |
| 61 | + apt-get update |
| 62 | + apt-get -y install docker.io |
| 63 | +
|
| 64 | + - name: Check out the repo |
| 65 | + uses: actions/checkout@v5 |
| 66 | + |
| 67 | + - name: Log in to Docker Hub |
| 68 | + uses: docker/login-action@v3 |
| 69 | + with: |
| 70 | + username: ${{ secrets.DOCKERHUB_USER }} |
| 71 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 72 | + |
| 73 | + - name: Set up Docker Buildx |
| 74 | + uses: docker/setup-buildx-action@v3 |
| 75 | + |
| 76 | + - name: Build and push ${{ inputs.target }} |
| 77 | + id: build |
| 78 | + uses: docker/build-push-action@v6 |
| 79 | + with: |
| 80 | + platforms: ${{ inputs.platform }} |
| 81 | + file: ${{ inputs.dockerfile }} |
| 82 | + build-args: | |
| 83 | + ARCH=${{ inputs.arch }} |
| 84 | + BRANCH=${{ inputs.branch }} |
| 85 | + outputs: type=image,name=firedrakeproject/${{ inputs.target }},push-by-digest=true,name-canonical=true,push=true |
| 86 | + |
| 87 | + - name: Export digest |
| 88 | + run: | |
| 89 | + : # Create a file in './digests' with name matching the pushed image hash |
| 90 | + mkdir digests |
| 91 | + digest="${{ steps.build.outputs.imageid }}" |
| 92 | + touch "digests/${digest#sha256:}" |
| 93 | +
|
| 94 | + - name: Upload digest |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: digests_${{ inputs.target }}_${{ inputs.os }} |
| 98 | + path: digests/* |
| 99 | + if-no-files-found: error |
| 100 | + retention-days: 1 |
| 101 | + |
| 102 | + - name: Post-cleanup |
| 103 | + if: always() |
| 104 | + run: find . -delete |
| 105 | + |
| 106 | + docker_build_macos: |
| 107 | + name: Build the ${{ inputs.target }} container (macOS) |
| 108 | + if: inputs.os == 'macOS' |
| 109 | + runs-on: [self-hosted, macOS] |
| 110 | + steps: |
| 111 | + - name: Pre-cleanup |
| 112 | + if: always() |
| 113 | + run: find . -delete |
59 | 114 |
|
60 | 115 | - name: Add homebrew to PATH |
61 | | - if: inputs.os == 'macOS' |
62 | 116 | run: | |
63 | 117 | : # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path |
64 | 118 | echo "/opt/homebrew/bin" >> "$GITHUB_PATH" |
@@ -88,21 +142,19 @@ jobs: |
88 | 142 |
|
89 | 143 | - name: Export digest |
90 | 144 | run: | |
91 | | - : # Create a file in <tempdir>/digests with name matching the pushed image hash |
92 | | - rm -rf ${{ runner.temp }}/digests |
93 | | - mkdir -p ${{ runner.temp }}/digests |
| 145 | + : # Create a file in digests with name matching the pushed image hash |
| 146 | + mkdir digests |
94 | 147 | digest="${{ steps.build.outputs.imageid }}" |
95 | | - touch "${{ runner.temp }}/digests/${digest#sha256:}" |
| 148 | + touch "digests/${digest#sha256:}" |
96 | 149 |
|
97 | 150 | - name: Upload digest |
98 | 151 | uses: actions/upload-artifact@v4 |
99 | 152 | with: |
100 | 153 | name: digests_${{ inputs.target }}_${{ inputs.os }} |
101 | | - path: ${{ runner.temp }}/digests/* |
| 154 | + path: digests/* |
102 | 155 | if-no-files-found: error |
103 | 156 | retention-days: 1 |
104 | 157 |
|
105 | 158 | - name: Post-cleanup |
106 | 159 | if: always() |
107 | | - run: | |
108 | | - rm -rf ${{ runner.temp }}/digests |
| 160 | + run: find . -delete |
0 commit comments