ci(rocky9-store): free runner disk space to avoid ENOSPC during publish #78
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: CI Publish rocky9-fs | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: | |
| - '*' | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| BUILD_TYPE: Release | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Record event type | |
| run: | | |
| branchName=$(echo "${{ github.ref_name }}") | |
| echo "BRANCH_NAME=$branchName" >> $GITHUB_ENV | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| echo "EVENT_TYPE=PR" >> $GITHUB_ENV | |
| echo "Skipping build steps for pull request event" | |
| elif [ "${{ github.event_name }}" == "push" ]; then | |
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| echo "EVENT_TYPE=TAG" >> $GITHUB_ENV | |
| tagInfo=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///') | |
| if [ -n "$tagInfo" ]; then | |
| echo "TAG_NAME=$tagInfo" >> $GITHUB_ENV | |
| fi | |
| else | |
| echo "EVENT_TYPE=PUSH" >> $GITHUB_ENV | |
| fi | |
| fi | |
| - name: Free disk space | |
| if: ${{ github.event_name == 'push'}} | |
| run: | | |
| df -h / | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /usr/local/.ghcup | |
| sudo swapoff -a || true | |
| sudo rm -f /mnt/swapfile || true | |
| sudo install -d -o "$USER" -g "$USER" -m 700 /mnt/tmp | |
| df -h / | |
| - name: Copy dingo-eureka repository | |
| if: ${{ github.event_name == 'push'}} | |
| run: | | |
| echo "Move dingo-eureka repository" | |
| sudo cp -r /home/runner/work/dingo-eureka/dingo-eureka /mnt/ | |
| sudo chown -R $USER:$USER /mnt/dingo-eureka | |
| echo "Remove original checkout on / to reclaim root-disk space" | |
| sudo rm -rf /home/runner/work/dingo-eureka/dingo-eureka | |
| mkdir -p /home/runner/work/dingo-eureka/dingo-eureka | |
| df -h / | |
| - name: Set Safe Dir | |
| if: ${{ github.event_name == 'push'}} | |
| run: git config --global --add safe.directory /mnt/dingo-eureka | |
| - name: Configure Docker data-root | |
| if: ${{ github.event_name == 'push'}} | |
| run: | | |
| sudo systemctl stop docker | |
| sudo systemctl stop docker.socket | |
| sudo mkdir -p /mnt/docker | |
| echo '{ "data-root": "/mnt/docker" }' | sudo tee /etc/docker/daemon.json | |
| if [ -d /var/lib/docker ]; then | |
| sudo mv /var/lib/docker /mnt/docker || true | |
| fi | |
| sudo systemctl start docker.socket | |
| sudo systemctl start docker | |
| docker info | grep "Docker Root Dir" | |
| - name: Sync submodules | |
| if: ${{ github.event_name == 'push'}} | |
| run: | | |
| cd /mnt/dingo-eureka | |
| git submodule sync --recursive | |
| git submodule update --init --recursive | |
| # - name: Clean .git directory | |
| # if: ${{ github.event_name == 'push'}} | |
| # run: | | |
| # find /mnt/dingo-eureka -name ".git" -type d -exec rm -rf {} + | |
| - name: Pull dingo-base:rocky9 | |
| if: ${{ github.event_name == 'push'}} | |
| run: | | |
| docker pull dingodatabase/dingo-base:rocky9 | |
| - name: Set up Docker Buildx | |
| if: ${{ github.event_name == 'push'}} | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| if: ${{ github.event_name == 'push'}} | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Docker meta of rocky9-fs | |
| if: ${{ github.event_name == 'push'}} | |
| id: rocky9-fs-meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: dingodatabase/dingo-eureka | |
| tags: | | |
| type=raw,value=rocky9-fs,enable=${{ env.EVENT_TYPE != 'tag' && github.ref_name == 'main' }} | |
| type=raw,value=rocky9-fs-${{ env.TAG_NAME }},enable=${{ env.EVENT_TYPE == 'tag' }} | |
| type=sha,prefix=rocky9-fs-,format=short,enable=${{ github.ref_name == 'main' && env.EVENT_TYPE != 'tag' }} | |
| type=sha,prefix=rocky9-fs-${{ github.ref_name }}-,format=short,enable=${{ env.EVENT_TYPE != 'tag' && github.ref_name != 'main' }} | |
| - name: Build and push 'dingo-eureka:rocky9-fs' | |
| if: ${{ github.event_name == 'push'}} | |
| env: | |
| TMPDIR: /mnt/tmp | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: /mnt/dingo-eureka | |
| file: /mnt/dingo-eureka/docker/eureka/rocky9/Dockerfile-fs | |
| push: true | |
| tags: ${{ steps.rocky9-fs-meta.outputs.tags }} | |