From ab9654387335074b078460662e22a1794ecd848c Mon Sep 17 00:00:00 2001 From: Tracey Jaquith Date: Sun, 7 Jan 2024 04:25:26 +0000 Subject: [PATCH] use a self-cleaning GitHub Actions to get around poopy GH runner size limits --- .github/workflows/cicd.yml | 63 +++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index dc91f90..c4e9ef8 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -2,14 +2,69 @@ name: CICD on: push jobs: cicd: + # this is a nice variante for HUGE repos runs-on: ubuntu-latest - permissions: { contents: read, packages: write, id-token: write } steps: - - uses: internetarchive/cicd@v1 + # this is like https://github.com/internetarchive/build/blob/main/action.yml + # BUT with `cache-to` and `cache-from` removed` (and the `password` field below isnt an input) + - name: Checkout repository + uses: actions/checkout@v4 + with: + lfs: true + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ghcr.io + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + + - name: Check working space directory1 + run: du ${GITHUB_WORKSPACE} -h -d 1 + + - name: Get more space + run: | + df . -h + sudo rm -rf ${GITHUB_WORKSPACE}/.git + df . -h + + - name: Check working space directory2 + run: du ${GITHUB_WORKSPACE} -h -d 1 + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + + - name: deploy + uses: internetarchive/deploy@v1 with: BASE_DOMAIN: 'dev.archive.org' NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }} REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NOMAD_VAR_HOSTNAMES: '["emularity-engine"]' NOMAD_VAR_COUNT: 1 - NOMAD_VAR_PORTS: '{ 80 = "http" }' + NOMAD_VAR_PORTS: '{ 80 = "http" }' + NOMAD_VAR_HOSTNAMES: '["emularity-engine"]'