From b76d700e68f07ba091b7ed0800001f0399f78a4e Mon Sep 17 00:00:00 2001 From: Paul Natsuo Kishimoto Date: Tue, 21 Jan 2025 10:29:00 +0100 Subject: [PATCH] Add workflows --- .github/workflows/pytest.yaml | 41 ++++++++++++++++++++++++++++++++++ .github/workflows/receive.yaml | 21 +++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/pytest.yaml create mode 100644 .github/workflows/receive.yaml diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml new file mode 100644 index 0000000..2522af4 --- /dev/null +++ b/.github/workflows/pytest.yaml @@ -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'!" diff --git a/.github/workflows/receive.yaml b/.github/workflows/receive.yaml new file mode 100644 index 0000000..c71a77b --- /dev/null +++ b/.github/workflows/receive.yaml @@ -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