Skip to content

Run scripts as non-root user #20

Run scripts as non-root user

Run scripts as non-root user #20

Workflow file for this run

name: Test
on:
push:
workflow_dispatch:
jobs:
pre-run:
name: Pre-run step executes
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: if [ -f pre-run ]; then echo "pre-run should not exist yet"; exit 1; fi
- uses: ./
with:
pre-run: touch pre-run
- run: if [ ! -f pre-run ]; then echo "pre-run should exist"; exit 1; fi
- run: if [ "$(id -u)" = "0" ]; then echo "current user should not be root"; exit 1; fi
pre-run-non-root:
name: Pre-run step executes as a user other than root
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./
with:
pre-run: if [ "$(id -u)" = "0" ]; then echo "current user should not be root"; exit 1; fi
run-in-vm:
name: Run-in-vm step executes
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: if [ -f run-in-vm ]; then echo "run-in-vm should not exist yet"; exit 1; fi
- uses: ./
with:
run-in-vm: uname -a > run-in-vm
- run: if [ ! -f run-in-vm ]; then echo "run-in-vm should exist (copied out of VM)"; exit 1; fi
- run: if ! grep -q "FreeBSD" run-in-vm; then echo "run-in-vm should contain FreeBSD"; exit 1; fi
post-run:
name: Post-run step executes
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: if [ -f post-run ]; then echo "post-run should not exist yet"; exit 1; fi
- uses: ./
with:
post-run: touch post-run
- run: if [ ! -f post-run ]; then echo "post-run should exist"; exit 1; fi
post-run-non-root:
name: Pre-run step executes as a user other than root
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./
with:
post-run: if [ "$(id -u)" = "0" ]; then echo "current user should not be root"; exit 1; fi