Add clean space step #4
Workflow file for this run
This file contains 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: Build and push image from develop | |
on: | |
push: | |
branches: | |
- '**' | |
jobs: | |
build-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login dockerhub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | |
- name: Clean space in the hosted machine | |
run: | | |
df -h | |
sudo swapoff -a | |
sudo rm -f /swapfile | |
sudo apt clean | |
docker rmi $(docker image ls -aq) | |
df -h | |
- name: Build & Push | |
uses: docker/build-push-action@v4 | |
id: built-image | |
with: | |
context: . | |
file: ./docker/Dockerfile | |
push: true | |
tags: tiicrc/claasp-lib-staging:test | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |