PR automations init #1679
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initialises all automations related to PR events. | |
# | |
# See `issue_automations.yml` for the corresponding implementation for issues. | |
# | |
# The automations for PR events are a little more complex than those for issues | |
# because PRs are a less secure environment. To avoid leaking secrets, we need | |
# to run automations with code as it appears on `main`. | |
# | |
# `pull_request_target` serves this purpose but there is no corresponding | |
# `_target` version for `pull_request_review`. So we take this roundabout | |
# approach: | |
# | |
# 1. This workflow runs for the events and their subtypes we are interested in. | |
# 2. It saves the event name, action and PR node ID to a JSON file. | |
# 3. It uploads the JSON file as an artifact. | |
# 4. Its completion triggers the `pr_automations.yml` workflow. | |
# | |
# continued in `pr_automations.yml`... | |
name: PR automations init | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- edited | |
- converted_to_draft | |
- ready_for_review | |
- closed | |
pull_request_review: | |
jobs: | |
run: | |
name: Save event info | |
runs-on: ubuntu-latest | |
steps: | |
- name: Save event info | |
run: | | |
echo '{"eventName": "'"$EVENT_NAME"'", "eventAction": "'"$EVENT_ACTION"'", "prNodeId": "'"$PR_NODE_ID"'"}' > /tmp/event.json | |
env: | |
EVENT_NAME: ${{ github.event_name }} | |
EVENT_ACTION: ${{ github.event.action }} | |
PR_NODE_ID: ${{ github.event.pull_request.node_id }} | |
- name: Upload event info as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: event_info | |
path: /tmp/event.json |