Skip to content

Commit 4b7cb01

Browse files
committed
build: update GHA workflow config
- update URLs to reference documentation - test on MacOS ARM and Intel - update versions of github actions (checkout, setup-java) - parameterize validate job so that in case of errors an SSH debug session can be opened
1 parent 79e2cf7 commit 4b7cb01

File tree

2 files changed

+75
-11
lines changed

2 files changed

+75
-11
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
1+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference
22
version: 2
33
updates:
44
- package-ecosystem: github-actions

.github/workflows/validate.yml

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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
22
name: Validate
33

4-
on:
4+
on: # https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows
55
push:
66
branches-ignore: # build all branches except:
77
- '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
99
- '**'
1010
paths-ignore:
1111
- '**/*.md'
@@ -18,27 +18,91 @@ on:
1818
- '.editorconfig'
1919
- '.git*'
2020
- '.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+
2239

2340
jobs:
41+
42+
###########################################################
2443
build:
25-
runs-on: ${{ matrix.os }}
44+
###########################################################
2645

2746
strategy:
2847
fail-fast: false
2948
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
3156

3257
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+
3368
- name: Git Checkout
34-
uses: actions/checkout@v4 # https://github.com/actions/checkout
69+
uses: actions/checkout@v5 # https://github.com/actions/checkout
3570

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
3874
with:
75+
distribution: temurin
3976
java-version: 11
40-
distribution: 'temurin'
4177
cache: gradle
4278

79+
4380
- name: Build with Gradle 🏗️
4481
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

Comments
 (0)