Skip to content

Commit 5306f04

Browse files
rbarker-devCopilot
andcommitted
feat: add setup task
Signed-off-by: Roger Barker <roger.barker@swirldslabs.com> chore: Update README Signed-off-by: Roger Barker <roger.barker@swirldslabs.com> chore: Update harden-runner Signed-off-by: Roger Barker <roger.barker@swirldslabs.com> chore: Fix GITHUB_TOKEN Signed-off-by: Roger Barker <roger.barker@swirldslabs.com> chore: Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Roger Barker <roger.barker@swirldslabs.com>
1 parent 0d2887e commit 5306f04

3 files changed

Lines changed: 71 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ jobs:
5656
rust-version: '1.70.0'
5757
setup-swift: true
5858
swift-version: '5.7'
59+
setup-task: true
60+
task-version: '3.50.0'
61+
task-retries: '3'
5962

6063
- name: Verify Setup
6164
run: |
@@ -329,3 +332,29 @@ jobs:
329332
echo "Swift Toolchain: ${{ steps.test-setup-swift.outputs.swift-toolchain }}"
330333
echo "Swift SDKs: ${{ steps.test-setup-swift.outputs.swift-sdks }}"
331334
swift --version
335+
336+
test-setup-task:
337+
name: Test Setup Task Action
338+
runs-on: ubuntu-latest
339+
steps:
340+
- name: Harden Runner
341+
id: harden-runner
342+
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
343+
with:
344+
egress-policy: audit
345+
346+
- name: Checkout Repository
347+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
348+
349+
- name: Run Setup Task Action
350+
uses: ./
351+
id: test-setup-task
352+
with:
353+
checkout-token: ${{ secrets.GITHUB_TOKEN }}
354+
setup-task: true
355+
task-version: '3.50.0'
356+
task-retries: '3'
357+
358+
- name: Verify Task Installation
359+
run: |
360+
task --version

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ Common steps for initializing a job for GitHub actions. This composite action co
100100
| swift-prefer-oss-toolchain | Whether to prefer Swift open source toolchain over Xcode | No | false |
101101
| swift-sdks | Semi-colon separated list of Swift SDKs to install | No | - |
102102

103+
**Task**
104+
105+
| Input | Description | Required | Default |
106+
|----------------|----------------------------------------------------------|----------|---------|
107+
| setup-task | Whether to setup Task | No | - |
108+
| task-version | Task version to use | No | 3.50.0 |
109+
| task-retries | Number of retries to set up task | No | 3 |
110+
| checkout-token | Personal access token (PAT) used to fetch the repository | No | - |
111+
103112
### Outputs
104113

105114
**Checkout Outputs**

action.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
description: 'The branch, tag or SHA to checkout'
1111
required: false
1212
checkout-token:
13-
description: 'Personal access token (PAT) used to fetch the repository'
13+
description: 'Personal access token (PAT) used to fetch the repository and set up task'
1414
required: false
1515
checkout-fetch-depth:
1616
description: 'Depth of commit history to fetch'
@@ -116,6 +116,18 @@ inputs:
116116
swift-sdks:
117117
description: 'Semi-colon separated list of Swift SDKs to install along with the main toolchain.'
118118
required: false
119+
setup-task:
120+
description: 'Whether to setup Task'
121+
required: false
122+
default: 'false'
123+
task-version:
124+
description: 'Task version to use'
125+
required: false
126+
default: '3.50.0'
127+
task-retries:
128+
description: 'Number of retries for Task setup in case of failure, default is 3.'
129+
required: false
130+
default: '3'
119131

120132
# expose outputs from the sub-actions
121133
outputs:
@@ -361,6 +373,26 @@ runs:
361373
prefer-oss-toolchain: ${{ inputs.swift-prefer-oss-toolchain == 'true' }}
362374
sdks: ${{ inputs.swift-sdks || '' }}
363375

376+
- name: Set Up Task Parameters
377+
id: setup-task-params
378+
if: ${{ inputs.setup-task == 'true' }}
379+
shell: bash
380+
run: |
381+
echo "::group::Setting up Task"
382+
echo "Version: ${{ inputs.task-version }}"
383+
echo "Repo Token Provided: ${{ inputs.checkout-token != '' }}"
384+
echo "Task Max Retries: ${{ inputs.task-retries }}"
385+
echo "::endgroup::"
386+
387+
- name: Setup Task
388+
id: setup-task
389+
if: ${{ inputs.setup-task == 'true' }}
390+
uses: go-task/setup-task@3be4020d41929789a01026e0e427a4321ce0ad44 # v3.50.0
391+
with:
392+
version: ${{ inputs.task-version }}
393+
repo-token: ${{ inputs.checkout-token }}
394+
max-retries: ${{ inputs.task-retries }}
395+
364396
branding:
365397
icon: 'arrow-up-right'
366398
color: 'green'

0 commit comments

Comments
 (0)