|
| 1 | +name: Docker image |
| 2 | +# Run the tasks on every push |
| 3 | +on: push |
| 4 | +jobs: |
| 5 | + build_push_api: |
| 6 | + name: Build and push execution environment |
| 7 | + runs-on: ubuntu-latest |
| 8 | + steps: |
| 9 | + - name: Check out the repository |
| 10 | + uses: actions/checkout@v2 |
| 11 | + |
| 12 | + - name: Set up Docker Buildx |
| 13 | + uses: docker/setup-buildx-action@v1 |
| 14 | + |
| 15 | + - name: Set up Docker layer caching |
| 16 | + uses: actions/cache@v2 |
| 17 | + with: |
| 18 | + path: /tmp/.buildx-cache |
| 19 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 20 | + restore-keys: | |
| 21 | + ${{ runner.os }}-buildx- |
| 22 | + - name: Login to GitHub Container Registry |
| 23 | + uses: docker/login-action@v1 |
| 24 | + with: |
| 25 | + registry: ghcr.io |
| 26 | + username: ${{ github.actor }} |
| 27 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + |
| 29 | + - name: Calculate metadata for image |
| 30 | + id: image-meta |
| 31 | + uses: docker/metadata-action@v3 |
| 32 | + with: |
| 33 | + images: ghcr.io/stackhpc/os-capacity |
| 34 | + # Produce the branch name or tag and the SHA as tags |
| 35 | + tags: | |
| 36 | + type=ref,event=branch |
| 37 | + type=ref,event=tag |
| 38 | + type=sha,prefix= |
| 39 | + - name: Build and push image |
| 40 | + uses: docker/build-push-action@v2 |
| 41 | + with: |
| 42 | + context: . |
| 43 | + push: true |
| 44 | + tags: ${{ steps.image-meta.outputs.tags }} |
| 45 | + labels: ${{ steps.image-meta.outputs.labels }} |
| 46 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 47 | + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max |
| 48 | + |
| 49 | + # Temp fix |
| 50 | + # https://github.com/docker/build-push-action/issues/252 |
| 51 | + # https://github.com/moby/buildkit/issues/1896 |
| 52 | + # https://github.com/docker/buildx/pull/535 |
| 53 | + - name: Move cache |
| 54 | + run: | |
| 55 | + rm -rf /tmp/.buildx-cache |
| 56 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments