Skip to content

workflows: Unsplit pr-subscriber #69748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/pr-receive-label.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/pr-subscriber-wait.py

This file was deleted.

52 changes: 5 additions & 47 deletions .github/workflows/pr-subscriber.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
name: PR Subscriber

on:
workflow_run:
workflows: ["PR Receive Label"]
pull_request_target:
types:
- completed
- labeled

permissions:
actions: read
contents: read

jobs:
auto-subscribe:
runs-on: ubuntu-latest
if: >
github.repository == 'llvm/llvm-project' &&
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
if: github.repository == 'llvm/llvm-project'
steps:
- name: Setup Automation Script
run: |
Expand All @@ -26,47 +21,10 @@ jobs:
chmod a+x github-automation.py
pip install -r requirements.txt

- name: 'Wait for other actions'
# We can't use the concurrency tag for these jobs, because it will
# cancel pending jobs if another job is running.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 pr-subscriber-wait.py


# From: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
# Updated version here: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
- name: 'Download artifact'
uses: actions/github-script@v6
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id
});
const matchArtifact = artifacts.data.artifacts.find((artifact) =>
artifact.name === 'pr'
);
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip'
});
const { writeFileSync } = require('node:fs');
writeFileSync('${{ github.workspace }}/pr.zip', Buffer.from(download.data));

- run: unzip pr.zip

- name: Update watchers
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
run: |
PR_NUMBER=$(cat NR)
LABEL_NAME=$(cat LABEL)
./github-automation.py \
--token '${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}' \
pr-subscriber \
--issue-number "$PR_NUMBER" \
--label-name "$LABEL_NAME"
--issue-number "${{ github.event.number }}" \
--label-name "${{ github.event.label.name }}"