Github self-hosted runner permission issues

github actions actions/checkout@v1 trigerring permission issues on self-hosted github runner

One or more errors occurred. (Access to the path ‘/pub/static/adminhtml/Magento/backend/en_US/info.json’ is denied.) (Access to the path ‘/magento/var/view_preprocessed/pub/static/adminhtml/Magento/backend/en_US/js-translation.json’ is denied.)

The solution is to clean the runner of the previous pulled repository

  - name: Cleaning up the $GITHUB_WORKSPACE as root from a Docker image
    run: find /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}/. -name . -o -prune -exec rm -rf -- {} + || true

Full sample

name: m2-actions-sips2-test

on: [push]

jobs:
  magento2-build:
    runs-on: self-hosted
    container: ubuntu
    name: 'm2 tests & build'
    steps:
      - name: Cleaning up the $GITHUB_WORKSPACE as root from a Docker image
        run: find /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}/. -name . -o -prune -exec rm -rf -- {} + || true
      - uses: actions/checkout@v1
        with:
          submodules: recursive
      - name: 'phpcs testing'
        uses: MAD-I-T/magento-actions@v3.10
        with:
          process: 'phpcs-test'
          extension: 'Madit/Sips2/'
          severity: 10
          standard: 'Magento2'

An better alternative is to install the runner service with to root permission on the server as follows:

sudo ./svc.sh install root
sudo ./svc.sh start