feat: Add known state change progress to 'Last Updated' field to show… #110
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: snd | |
| on: | |
| push: | |
| branches: | |
| - "snd" | |
| paths-ignore: | |
| - '*.md' | |
| - 'images/**' | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.platform_tag }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: [self-hosted, Linux, X64] | |
| platform: linux/amd64 | |
| platform_tag: amd64 | |
| - runner: [self-hosted, Linux, ARM64] | |
| platform: linux/arm64 | |
| platform_tag: arm64 | |
| steps: | |
| - name: Clean workspace | |
| if: always() | |
| run: | | |
| sudo chown -R $USER:$USER ${{ github.workspace }} || true | |
| sudo rm -rf ${{ github.workspace }}/* ${{ github.workspace }}/.* 2>/dev/null || true | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: snd | |
| clean: false | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set cache paths | |
| run: | | |
| echo "CACHE_PATH=${HOME}/.cache/buildx" >> $GITHUB_ENV | |
| echo "CACHE_PATH_NEW=${HOME}/.cache/buildx-new" >> $GITHUB_ENV | |
| - name: Cache Docker layers | |
| # Skip GitHub Actions cache for self-hosted runners (files persist locally) | |
| if: ${{ !contains(runner.labels, 'self-hosted') }} | |
| uses: actions/cache@v4 | |
| with: | |
| # CHANGE: Use a path in the home directory, not /tmp | |
| path: ~/.cache/buildx | |
| key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx-${{ github.ref_name }}- | |
| ${{ runner.os }}-buildx- | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| # Push to a temporary tag specific to the architecture (e.g., :snd-arm64) | |
| tags: ${{ vars.DOCKERHUB_USERNAME }}/simpleclouddetect:snd-${{ matrix.platform_tag }} | |
| # Use persistent cache on self-hosted runner | |
| cache-from: type=local,src=${{ env.CACHE_PATH }} | |
| cache-to: type=local,dest=${{ env.CACHE_PATH_NEW }},mode=min | |
| platforms: ${{ matrix.platform }} | |
| - name: Move cache | |
| if: always() | |
| run: | | |
| rm -rf ${{ env.CACHE_PATH }} | |
| if [ -d "${{ env.CACHE_PATH_NEW }}" ]; then | |
| mv ${{ env.CACHE_PATH_NEW }} ${{ env.CACHE_PATH }} | |
| fi | |
| merge: | |
| name: Merge Multi-Arch Image | |
| needs: build | |
| runs-on: [self-hosted, Linux, X64] | |
| steps: | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Create and push manifest list | |
| # Combines the amd64 and arm64 tags into the single ':snd' tag | |
| run: | | |
| docker buildx imagetools create -t ${{ vars.DOCKERHUB_USERNAME }}/simpleclouddetect:snd \ | |
| ${{ vars.DOCKERHUB_USERNAME }}/simpleclouddetect:snd-amd64 \ | |
| ${{ vars.DOCKERHUB_USERNAME }}/simpleclouddetect:snd-arm64 | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ vars.DOCKERHUB_USERNAME }}/simpleclouddetect:snd | |
| - name: Get image size | |
| run: | | |
| docker pull ${{ vars.DOCKERHUB_USERNAME }}/simpleclouddetect:snd | |
| IMAGE_SIZE=$(docker images --format "{{.Size}}" ${{ vars.DOCKERHUB_USERNAME }}/simpleclouddetect:snd | head -n1) | |
| echo "Docker image size: $IMAGE_SIZE" |