Deploy command anyone can run
An issue_comment workflow deploys when a comment contains /deploy, without checking who wrote it.
issue_comment runs for every comment on every issue and pull request, from anyone. This workflow only checks that the comment contains /deploy, then runs with write-all permissions and the deploy key, and pastes the whole comment into the deploy command.
Check who commented (github.event.comment.author_association) before doing anything privileged, and keep the comment out of scripts.
# Deploys a preview when someone comments "/deploy" on a pull request.# Anyone can comment, and the job runs with the deploy key.name: Deploy on comment on: issue_comment: types: [created] jobs: deploy: if: contains(github.event.comment.body, '/deploy') runs-on: ubuntu-latest permissions: write-all steps: - uses: actions/checkout@v4 - name: Deploy run: ./scripts/deploy.sh "${{ github.event.comment.body }}" env: DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}