|
| 1 | +name: Step 1, 1-Copilot Extension in a Codespace |
| 2 | + |
| 3 | +# This step triggers after TBD-step-1-event-desc |
| 4 | +# This step sets STEP to 2 |
| 5 | +# This step closes <details id=1> and opens <details id=2> |
| 6 | + |
| 7 | +# This will run every time we TBD-step-1-event-desc |
| 8 | +# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | + push: |
| 12 | + paths: |
| 13 | + - '.devcontainer/devcontainer.json' |
| 14 | + branches: |
| 15 | + - main |
| 16 | + |
| 17 | +# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication |
| 18 | +permissions: |
| 19 | + # Need `contents: read` to checkout the repository |
| 20 | + # Need `contents: write` to update the step metadata |
| 21 | + contents: write |
| 22 | + |
| 23 | +jobs: |
| 24 | + # The purpose of this job is to output the current step number |
| 25 | + # (retreived from the STEP file). This output variable can |
| 26 | + # then be referenced in other jobs and used in conditional |
| 27 | + # expressions. |
| 28 | + get_current_step: |
| 29 | + name: Check current step number |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v3 |
| 34 | + - id: get_step |
| 35 | + run: echo "::set-output name=current_step::$(cat ./.github/script/STEP)" |
| 36 | + outputs: |
| 37 | + current_step: ${{ steps.get_step.outputs.current_step }} |
| 38 | + |
| 39 | + on_add_devcontainer: |
| 40 | + name: On Add Devcontainer |
| 41 | + needs: get_current_step |
| 42 | + |
| 43 | + # We will only run this action when: |
| 44 | + # 1. This repository isn't the template repository |
| 45 | + # Reference https://docs.github.com/en/actions/learn-github-actions/contexts |
| 46 | + # Reference https://docs.github.com/en/actions/learn-github-actions/expressions |
| 47 | + if: ${{ !github.event.repository.is_template && needs.get_current_step.outputs.current_step == 1 }} |
| 48 | + |
| 49 | + # We'll run Ubuntu for performance instead of Mac or Windows |
| 50 | + runs-on: ubuntu-latest |
| 51 | + |
| 52 | + steps: |
| 53 | + # We'll need to check out the repository so that we can edit the README |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v2 |
| 56 | + |
| 57 | + # Verify the learner added the file contents |
| 58 | + - name: Check workflow contents, jobs |
| 59 | + run: | |
| 60 | + chmod a+x .github/script/check-file.sh |
| 61 | + ./.github/script/check-file.sh |
| 62 | + env: |
| 63 | + FILE: ".devcontainer/devcontainer.json" |
| 64 | + SEARCH: "GitHub.copilot" |
| 65 | + |
| 66 | + # Update README to close <details id=1> and open <details id=2> |
| 67 | + # and set STEP to '2' |
| 68 | + - name: Update to step 2 |
| 69 | + uses: skills/action-update-step@v1 |
| 70 | + with: |
| 71 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + from_step: 1 |
| 73 | + to_step: 2 |
0 commit comments