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 b76d700
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test

on:
workflow_run:
workflows: [ "Receive pull request" ]
types: [ completed ]

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

jobs:
pytest:
if: >
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest

steps:
- name: Debug workflow_run payload
run: echo "${{ toJSON(github.event.workflow_run) }}"

- name: Check out repo
if: github.event_name != 'workflow_run'
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}

- name: Check out repo (workflow_run)
if: github.event_name == 'workflow_run'
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}
repository: ${{ github.event.workflow_run.head_repository.fullname }}
ref: ${{ github.event.workflow_run.head_branch }}

- 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 b76d700

Please sign in to comment.