Skip to content

Commit

Permalink
Add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Jan 21, 2025
1 parent bddc2a6 commit eb5f0b6
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
pull_request_target:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
check:
name: Check permissions
runs-on: ubuntu-latest
steps:
- if: >
github.repository != github.event.pull_request.head.repo.full_name &&
! contains(github.event.pull_request.labels.*.name, 'safe to test')
run: |
echo "Pytest workflow will not run for branch in fork without label \`safe to test\`." >>$GITHUB_STEP_SUMMARY
exit 1
pytest:
needs: [ check ]
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest

runs-on: ${{ matrix.os }}

steps:
- name: Check out repo
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}
ref: ${{ github.event.pull_request.head.sha }}

- name: Leak a secret
env:
BAR: ${{ secrets.FOO }}
run: echo "'FOO' secret contains '$BAR'!"
21 changes: 21 additions & 0 deletions .github/workflows/receive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Receive pull request

on:
pull_request:
branches: [ main ]

env:
label: "safe to test"

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Ensure first-party branch or valid label
if: >
github.repository != github.event.pull_request.head.repo.full_name &&
! contains(github.event.pull_request.labels.*.name, env.label)
run: |
echo "Will not run \`pytest\` workflow for branch in fork without label \`${{ env.label }}\`." >>$GITHUB_STEP_SUMMARY
exit 1

0 comments on commit eb5f0b6

Please sign in to comment.