Skip to content

CI/CD: Additional build stage cleanup #59

CI/CD: Additional build stage cleanup

CI/CD: Additional build stage cleanup #59

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Docker Image
# Controls when the action will run.
on:
# When a release is published
release:
types: [published]
# Push excluding tags and workflow changes
push:
branches:
- main
tags-ignore:
- '*.*'
paths-ignore:
- '**/*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
image_postgresql:
env:
PLATFORM: linux/amd64,linux/aarch64
runs-on: ubuntu-latest
steps:
- name: Free up disk space
run: |
echo "Disk space before cleanup:"
df -h
# Remove large directories
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
# Remove large packages
sudo apt-get remove -y '^aspnetcore-.*' || true
sudo apt-get remove -y '^dotnet-.*' || true
sudo apt-get remove -y '^llvm-.*' || true
sudo apt-get remove -y 'php.*' || true
sudo apt-get remove -y '^mongodb-.*' || true
sudo apt-get remove -y '^mysql-.*' || true
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri || true
sudo apt-get remove -y google-cloud-sdk google-cloud-cli || true
sudo apt-get autoremove -y
sudo apt-get clean
# Remove Docker images
sudo docker image prune --all --force
# Remove swap storage
sudo swapoff -a || true
sudo rm -f /mnt/swapfile || true
echo "Disk space after cleanup:"
df -h
- name: Set tags
run: |
if [ -z "$TAG" ]; then
echo "TAG=-t openremote/postgresql:develop" >> $GITHUB_ENV
else
echo "TAG=-t openremote/postgresql:latest -t openremote/postgresql:$TAG" >> $GITHUB_ENV
fi
env:
TAG: ${{ github.event.release.tag_name }}
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392
with:
platforms: all
- name: install buildx
id: buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
with:
version: latest
install: true
- name: available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to DockerHub
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
with:
username: ${{ secrets._TEMP_DOCKERHUB_USER }}
password: ${{ secrets._TEMP_DOCKERHUB_PASSWORD }}
- name: build and push images
run: |
docker buildx build \
--build-arg GIT_COMMIT=${{ github.sha }} \
--push \
--platform $PLATFORM \
--no-cache-filter trimmed \
--no-cache-filter trimmed-all \
$TAG .