From c36b5fee469850c6cb6a11f9e866f3000c2848f8 Mon Sep 17 00:00:00 2001 From: Kati Lassila-Perini Date: Tue, 10 Oct 2023 20:33:59 +0200 Subject: [PATCH 1/4] Create docker-publish.yml --- .github/workflows/docker-publish.yml | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..49ffe25 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,62 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [ "main" ] + # Publish semver tags as releases. + tags: [ 'v*' ] + pull_request: + branches: [ "main" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ${{ env.REGISTRY }} + 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@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # 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@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From d05cf079234487747a8721a9470ca3df8792e833 Mon Sep 17 00:00:00 2001 From: Kati Lassila-Perini Date: Tue, 10 Oct 2023 20:54:33 +0200 Subject: [PATCH 2/4] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 49ffe25..8e16bab 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,6 +29,13 @@ jobs: packages: write steps: + - name: Free some disk space + uses: AdityaGarg8/remove-unwanted-software@v1 + with: + remove-android: 'true' + remove-dotnet: 'true' + remove-haskell: 'true' + - name: Checkout repository uses: actions/checkout@v3 From 07b02f07527252a2121ce81051a8a420055e84da Mon Sep 17 00:00:00 2001 From: Kati Lassila-Perini Date: Tue, 10 Oct 2023 21:22:59 +0200 Subject: [PATCH 3/4] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8e16bab..25c9af0 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -35,6 +35,16 @@ jobs: remove-android: 'true' remove-dotnet: 'true' remove-haskell: 'true' + + - name: Free some more space + with: + docker rmi `docker images -q` + sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d + sudo apt -y autoremove --purge + sudo apt -y autoclean + sudo apt clean + rm --recursive --force "$AGENT_TOOLSDIRECTORY" + df -h - name: Checkout repository uses: actions/checkout@v3 From cdfa8fc159cf75e67ac260a2bbe3dfa72285c41b Mon Sep 17 00:00:00 2001 From: Kati Lassila-Perini Date: Tue, 10 Oct 2023 21:24:46 +0200 Subject: [PATCH 4/4] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 25c9af0..35f3aa0 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -37,7 +37,7 @@ jobs: remove-haskell: 'true' - name: Free some more space - with: + run: | docker rmi `docker images -q` sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/sudo apt/sources.list.d sudo apt -y autoremove --purge