Skip to content

.github/workflows/test-cleanup-workspace.yml #79

.github/workflows/test-cleanup-workspace.yml

.github/workflows/test-cleanup-workspace.yml #79

on:
pull_request:
paths:
- ".github/workflows/test-cleanup-workspace.yml"
push:
branches: [main]
paths:
- ".github/workflows/test-cleanup-workspace.yml"
workflow_dispatch:
schedule:
- cron: "0 8 * * *"
defaults:
run:
shell: bash
jobs:
test-cleanup-before-checkout:
strategy:
matrix:
os: [macos15, windows]
runs-on: ${{ matrix.os }}
steps:
- name: Determine workspace
run: |
WORKSPACE='${{ github.workspace }}'
if [ '${{ runner.os }}' = 'Windows' ]; then
WORKSPACE=$(cygpath -u "${WORKSPACE}")
fi
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
- name: Create files in workspace
run: |
touch "${WORKSPACE}/testfile"
mkdir -p "${WORKSPACE}/testdir"
touch "${WORKSPACE}/testdir/inner_testfile"
mkdir -p "${WORKSPACE}/.git"
touch "${WORKSPACE}/.git/inner_gitfile"
- name: List files in workspace
run: |
ls -RA "${WORKSPACE}"
# Using the hash-pinned version, because we want to test it works before checkout
- name: Cleanup workspace
uses: XRPLF/actions/cleanup-workspace@cf0433aa74563aead044a1e395610c96d65a37cf
- name: Check that workspace is empty
run: |
if [ "$(ls -A ${WORKSPACE})" ]; then
echo "Workspace is not empty"
exit 1
else
echo "Workspace is empty"
fi
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1