|
1 | | -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions |
| 1 | +# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax |
2 | 2 | name: Validate |
3 | 3 |
|
4 | | -on: |
| 4 | +on: # https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows |
5 | 5 | push: |
6 | 6 | branches-ignore: # build all branches except: |
7 | 7 | - 'dependabot/**' # prevent workflow being triggered twice (once for commit to the branch and once for opening/syncing the PR) |
8 | | - tags-ignore: # don't build tags |
| 8 | + tags-ignore: # don't build tags |
9 | 9 | - '**' |
10 | 10 | paths-ignore: |
11 | 11 | - '**/*.md' |
|
18 | 18 | - '.editorconfig' |
19 | 19 | - '.git*' |
20 | 20 | - '.github/*.yml' |
21 | | - workflow_dispatch: # https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/ |
| 21 | + workflow_dispatch: |
| 22 | + # https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_dispatch |
| 23 | + inputs: |
| 24 | + debug-with-ssh: |
| 25 | + description: "When to open an SSH session for post-build debugging:" |
| 26 | + default: never |
| 27 | + type: choice |
| 28 | + options: [ always, on_failure, on_failure_or_cancelled, never ] |
| 29 | + debug-with-ssh-only-for-actor: |
| 30 | + description: "Restrict SSH debug session access to the GitHub user who triggered the workflow" |
| 31 | + default: true |
| 32 | + type: boolean |
| 33 | + |
| 34 | + |
| 35 | +defaults: |
| 36 | + run: |
| 37 | + shell: bash |
| 38 | + |
22 | 39 |
|
23 | 40 | jobs: |
| 41 | + |
| 42 | + ########################################################### |
24 | 43 | build: |
25 | | - runs-on: ${{ matrix.os }} |
| 44 | + ########################################################### |
26 | 45 |
|
27 | 46 | strategy: |
28 | 47 | fail-fast: false |
29 | 48 | matrix: |
30 | | - os: [ubuntu-latest, windows-latest, macos-latest] |
| 49 | + os: # https://github.com/actions/runner-images#available-images |
| 50 | + - ubuntu-latest |
| 51 | + - macos-15-intel # Intel |
| 52 | + - macos-latest # ARM |
| 53 | + - windows-latest |
| 54 | + runs-on: ${{ matrix.os }} |
| 55 | + timeout-minutes: 20 |
31 | 56 |
|
32 | 57 | steps: |
| 58 | + - name: "Show: GitHub context" |
| 59 | + env: |
| 60 | + GITHUB_CONTEXT: ${{ toJSON(github) }} |
| 61 | + run: echo $GITHUB_CONTEXT |
| 62 | + |
| 63 | + |
| 64 | + - name: "Show: environment variables" |
| 65 | + run: env | sort |
| 66 | + |
| 67 | + |
33 | 68 | - name: Git Checkout |
34 | | - uses: actions/checkout@v4 # https://github.com/actions/checkout |
| 69 | + uses: actions/checkout@v5 # https://github.com/actions/checkout |
35 | 70 |
|
36 | | - - name: Set up JDK 11 ☕ |
37 | | - uses: actions/setup-java@v4 |
| 71 | + |
| 72 | + - name: "Install: JDK 11 ☕" |
| 73 | + uses: actions/setup-java@v5 # https://github.com/actions/setup-java |
38 | 74 | with: |
| 75 | + distribution: temurin |
39 | 76 | java-version: 11 |
40 | | - distribution: 'temurin' |
41 | 77 | cache: gradle |
42 | 78 |
|
| 79 | + |
43 | 80 | - name: Build with Gradle 🏗️ |
44 | 81 | run: ./gradlew build |
| 82 | + |
| 83 | + |
| 84 | + ################################################## |
| 85 | + # Setup SSH debug session |
| 86 | + ################################################## |
| 87 | + - name: "SSH session for debugging: check" |
| 88 | + id: DEBUG_SSH_SESSSION_CHECK |
| 89 | + if: always() |
| 90 | + run: | |
| 91 | + set -eu |
| 92 | +
|
| 93 | + when="${{ inputs.debug-with-ssh }}" |
| 94 | +
|
| 95 | + if [[ $when == "always" ]] || case "${{ job.status }}" in |
| 96 | + success) [[ $when == "always" ]] ;; |
| 97 | + cancelled) [[ $when == "on_failure_or_cancelled" ]] ;; |
| 98 | + failure) [[ $when == "on_failure"* ]] ;; |
| 99 | + esac; then |
| 100 | + echo "start_ssh_session=true" | tee -a "$GITHUB_OUTPUT" |
| 101 | + fi |
| 102 | +
|
| 103 | +
|
| 104 | + - name: "SSH session for debugging: start" |
| 105 | + uses: mxschmitt/action-tmate@v3 # https://github.com/mxschmitt/action-tmate |
| 106 | + if: always() && steps.DEBUG_SSH_SESSSION_CHECK.outputs.start_ssh_session |
| 107 | + with: |
| 108 | + limit-access-to-actor: ${{ inputs.debug-with-ssh-only-for-actor }} |
0 commit comments