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 81eb942
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
on:
pull_request_target:
branches: [ main ]
# workflow_run:
# workflows: [ "Receive pull request" ]
# types: [ completed ]

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

env:
label: "safe to test"

jobs:
fail:
if: >
github.repository != github.event.pull_request.head.repo.full_name &&
! contains(github.event.pull_request.labels.*.name, env.label)
runs-on: ubuntu-latest

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

steps:
- name: Debug GitHub Actions payloads
run: |
echo "${{ toJSON(github.triggering_actor) }}"
echo "${{ toJSON(github.event.pull_request) }}"
echo "${{ toJSON(github.event.workflow_run) }}"
- name: Check out repo (pull_request_target)
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}
ref: ${{ github.event.pull_request.head.sha }}

# - 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.full_name }}
# 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 81eb942

Please sign in to comment.