|
| 1 | +name: Step 3, Open a pull request |
| 2 | + |
| 3 | +# This step listens for the learner to open a pull request with branch `my-first-branch` |
| 4 | +# This step sets STEP to 4 |
| 5 | +# This step closes <details id=3> and opens <details id=4> |
| 6 | + |
| 7 | +# This will run every time we create a branch or tag |
| 8 | +# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | + pull_request: |
| 12 | + types: |
| 13 | + - opened |
| 14 | + - reopened |
| 15 | + |
| 16 | +# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication |
| 17 | +permissions: |
| 18 | + # Need `contents: read` to checkout the repository |
| 19 | + # Need `contents: write` to update the step metadata |
| 20 | + contents: write |
| 21 | + |
| 22 | +jobs: |
| 23 | + on_open_a_pull_request: |
| 24 | + name: On open a pull request |
| 25 | + |
| 26 | + # We will only run this action when: |
| 27 | + # 1. This repository isn't the template repository |
| 28 | + # 2. The head branch name is `my-first-branch` |
| 29 | + # Reference https://docs.github.com/en/actions/learn-github-actions/contexts |
| 30 | + # Reference https://docs.github.com/en/actions/learn-github-actions/expressions |
| 31 | + if: ${{ !github.event.repository.is_template && github.head_ref == 'my-first-branch' }} |
| 32 | + |
| 33 | + # We'll run Ubuntu for performance instead of Mac or Windows |
| 34 | + runs-on: ubuntu-latest |
| 35 | + |
| 36 | + steps: |
| 37 | + # We'll need to check out the repository so that we can edit the README |
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@v2 |
| 40 | + with: |
| 41 | + fetch-depth: 0 # Let's get all the branches |
| 42 | + ref: my-first-branch # Important, as normally `pull_request` event won't grab other branches |
| 43 | + |
| 44 | + # Update README to close <details id=3> and open <details id=4> |
| 45 | + # and set STEP to '4' |
| 46 | + - name: Update to step 4 |
| 47 | + uses: skills/action-update-step@v1 |
| 48 | + with: |
| 49 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + from_step: 3 |
| 51 | + to_step: 4 |
| 52 | + branch_name: my-first-branch |
0 commit comments