Skip to content

Commit 3259c23

Browse files
authored
Merge pull request #1 from snow-actions/create-action
Create action
2 parents 5b8c1f4 + ee3b549 commit 3259c23

File tree

5 files changed

+143
-107
lines changed

5 files changed

+143
-107
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @actions/actions-runtime
1+
* @SnowCait

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ updates:
33
- package-ecosystem: github-actions
44
directory: /
55
schedule:
6-
interval: daily
6+
interval: monthly

.github/workflows/test.yml

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,70 +8,81 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
test-bash:
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
# Runs on all supported runners
16-
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
17-
os: [ ubuntu-22.04, ubuntu-20.04, ubuntu-18.04, windows-2022, windows-2019, macos-11, macos-10.15 ]
18-
runs-on: ${{ matrix.os }}
11+
runners:
12+
runs-on: ubuntu-latest
1913
timeout-minutes: 5
20-
defaults:
21-
run:
22-
shell: bash
23-
14+
outputs:
15+
list: ${{ steps.list.outputs.all }}
2416
steps:
2517
- uses: actions/checkout@v3
26-
27-
- id: without-parameters
18+
- id: list
2819
uses: ./
29-
- run: test "${GREET}" = "Hello World"
30-
env:
31-
GREET: ${{ steps.without-parameters.outputs.greet }}
32-
- run: test "$(cat greet.txt)" = "Hello World"
3320

34-
- id: with-parameters
35-
uses: ./
36-
with:
37-
who-to-greet: composite action
38-
- run: test "${GREET}" = "Hello composite action"
39-
env:
40-
GREET: ${{ steps.with-parameters.outputs.greet }}
41-
- run: test "$(cat greet.txt)" = "Hello composite action"
42-
43-
test-powershell:
21+
test:
22+
needs: [ runners ]
4423
strategy:
4524
fail-fast: false
4625
matrix:
47-
os: [ windows-2022, windows-2019 ]
48-
runs-on: ${{ matrix.os }}
26+
runner: ${{ fromJSON(needs.runners.outputs.list) }}
27+
runs-on: ${{ matrix.runner }}
4928
timeout-minutes: 5
50-
5129
steps:
5230
- uses: actions/checkout@v3
53-
54-
- id: without-parameters
31+
- id: list
5532
uses: ./
56-
- run: test "${env:GREET}" = "Hello World"
33+
- run: echo "${json}"
5734
env:
58-
GREET: ${{ steps.without-parameters.outputs.greet }}
59-
- run: test "$(cat greet.txt)" = "Hello World"
35+
json: ${{ toJSON(steps.list.outputs) }}
6036

61-
- id: with-parameters
62-
uses: ./
63-
with:
64-
who-to-greet: composite action
65-
- run: test "${env:GREET}" = "Hello composite action"
37+
- name: All list length > 0
38+
run: test $(echo ${list} | jq 'length') -gt 0
39+
env:
40+
list: ${{ steps.list.outputs.all }}
41+
shell: bash
42+
- name: All list doesn't contain latest
43+
run: test $(echo ${list} | jq 'map(select(endswith("-latest"))) | length') -eq 0
6644
env:
67-
GREET: ${{ steps.with-parameters.outputs.greet }}
68-
- run: test "$(cat greet.txt)" = "Hello composite action"
45+
list: ${{ steps.list.outputs.all }}
46+
shell: bash
47+
- name: Latest list length == 3
48+
run: test $(echo ${list} | jq 'length') -eq 3
49+
env:
50+
list: ${{ steps.list.outputs.latest }}
51+
shell: bash
52+
- name: Ubuntu list length > 0
53+
run: test $(echo ${list} | jq 'length') -gt 0
54+
env:
55+
list: ${{ steps.list.outputs.ubuntu }}
56+
shell: bash
57+
- name: Ubuntu list doesn't contain latest
58+
run: test $(echo ${list} | jq 'map(select(endswith("-latest"))) | length') -eq 0
59+
env:
60+
list: ${{ steps.list.outputs.ubuntu }}
61+
shell: bash
62+
- name: Windows list length > 0
63+
run: test $(echo ${list} | jq 'length') -gt 0
64+
env:
65+
list: ${{ steps.list.outputs.windows }}
66+
shell: bash
67+
- name: Windows list doesn't contain latest
68+
run: test $(echo ${list} | jq 'map(select(endswith("-latest"))) | length') -eq 0
69+
env:
70+
list: ${{ steps.list.outputs.windows }}
71+
shell: bash
72+
- name: macOS list length > 0
73+
run: test $(echo ${list} | jq 'length') -gt 0
74+
env:
75+
list: ${{ steps.list.outputs.macos }}
76+
shell: bash
77+
- name: macOS list doesn't contain latest
78+
run: test $(echo ${list} | jq 'map(select(endswith("-latest"))) | length') -eq 0
79+
env:
80+
list: ${{ steps.list.outputs.macos }}
81+
shell: bash
6982

70-
# Make up matrix statuses into a status for status checks in branch protection rules
7183
test-passing:
72-
needs: [ test-bash, test-powershell ]
84+
needs: [ test ]
7385
runs-on: ubuntu-latest
74-
timeout-minutes: 1
75-
86+
timeout-minutes: 5
7687
steps:
7788
- run: echo "All tests have passed."

README.md

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,41 @@
1-
[![Test](https://github.com/snow-actions/composite-action-template/actions/workflows/test.yml/badge.svg)](https://github.com/snow-actions/composite-action-template/actions/workflows/test.yml)
1+
# GitHub-hosted runners
22

3-
# Create a Composite Action
3+
[![Test](https://github.com/snow-actions/github-hosted-runners/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/snow-actions/github-hosted-runners/actions/workflows/test.yml)
44

5-
Click the `Use this template` to bootstrap the creation of a [composite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action).:rocket:
6-
7-
This template includes tests, a validation workflow and versioning guidance.
8-
9-
Learn how to use this template at [Wiki](https://github.com/snow-actions/composite-action-template/wiki).
5+
The list of [GitHub-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources).
106

117
## Usage
128

13-
### Basic
14-
15-
```yml
16-
steps:
17-
- uses: snow-actions/[email protected]
18-
```
19-
20-
### Optional
21-
229
```yml
23-
steps:
24-
- uses: snow-actions/[email protected]
25-
with:
26-
who-to-greet: Your name
10+
jobs:
11+
runners:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
list: ${{ steps.list.outputs.all }}
15+
steps:
16+
- id: list
17+
uses: snow-actions/[email protected]
18+
19+
test:
20+
needs: [ runners ]
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
runner: ${{ fromJSON(needs.runners.outputs.list) }}
25+
runs-on: ${{ matrix.runner }}
2726
```
2827
29-
## Environment variables
30-
31-
| Name | Description | Default | Required |
32-
| - | - | - | - |
33-
| `WHO_TO_GREET` | Who to greet | `World` | no |
34-
35-
## Inputs
36-
37-
See [action.yml](action.yml)
38-
39-
| Name | Description | Default | Required |
40-
| - | - | - | - |
41-
| `who-to-greet` | Who to greet | `World` | yes |
42-
4328
## Outputs
4429
4530
See [action.yml](action.yml)
4631
4732
| Name | Description |
4833
| - | - |
49-
| `greet` | The word we greeted you |
34+
| `all` | All runners |
35+
| `latest` | Latest runners |
36+
| `ubuntu` | Ubuntu runners |
37+
| `windows` | Windows runners |
38+
| `macos` | macOS runners |
5039

5140
## Supported
5241

@@ -60,16 +49,13 @@ See [action.yml](action.yml)
6049
### Events
6150

6251
- Any
63-
<!--
64-
- `push`
65-
- `pull_request`
66-
-->
6752

6853
## Dependencies
6954

7055
- Bash
71-
- [actions/cache](https://github.com/actions/cache) >= 3.0.0
72-
- [GitHub CLI](https://cli.github.com/) >= 2.6.0
56+
- cURL
57+
- [jq](https://stedolan.github.io/jq/)
58+
- [JSON Schema Store](https://www.schemastore.org/json/)
7359

7460
## Contributing
7561

action.yml

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,65 @@
1-
name: Composite Action Template
2-
description: Get started with Composite actions
1+
name: GitHub-hosted runners
2+
description: The list of GitHub-hosted runners
33
branding:
4-
icon: award
4+
icon: list
55
color: green
6-
inputs:
7-
who-to-greet:
8-
description: Who to greet
9-
required: true
10-
default: World
116
outputs:
12-
greet:
13-
description: The word we greeted you
14-
value: ${{ steps.greet.outputs.word }}
7+
all:
8+
description: All runners
9+
value: ${{ steps.all.outputs.json }}
10+
latest:
11+
description: Latest runners
12+
value: ${{ steps.latest.outputs.json }}
13+
ubuntu:
14+
description: Ubuntu runners
15+
value: ${{ steps.ubuntu.outputs.json }}
16+
windows:
17+
description: Windows runners
18+
value: ${{ steps.windows.outputs.json }}
19+
macos:
20+
description: macOS runners
21+
value: ${{ steps.macos.outputs.json }}
1522
runs:
1623
using: composite
1724
steps:
18-
- id: greet
25+
- id: list
1926
run: |
20-
GREET="Hello ${WHO}"
21-
echo "${GREET}"
22-
echo "${GREET}" > greet.txt
23-
echo "::set-output name=word::${GREET}"
27+
json=$(curl -sS https://json.schemastore.org/github-workflow.json \
28+
| jq -c '.definitions.normalJob.properties["runs-on"].oneOf | map(select(.type == "string")) | first | .enum | map(select(. != "self-hosted"))')
29+
echo "json=${json}" >> $GITHUB_OUTPUT
2430
shell: bash
31+
- id: all
32+
run: |
33+
json=$(echo ${list} | jq -c 'map(select(endswith("-latest") | not))')
34+
echo "json=${json}" >> $GITHUB_OUTPUT
35+
env:
36+
list: ${{ steps.list.outputs.json }}
37+
shell: bash
38+
- id: latest
39+
run: |
40+
json=$(echo ${list} | jq -c 'map(select(endswith("-latest")))')
41+
echo "json=${json}" >> $GITHUB_OUTPUT
42+
env:
43+
list: ${{ steps.list.outputs.json }}
44+
shell: bash
45+
- id: ubuntu
46+
run: |
47+
json=$(echo ${list} | jq -c 'map(select(startswith("ubuntu-") and (endswith("-latest") | not)))')
48+
echo "json=${json}" >> $GITHUB_OUTPUT
2549
env:
26-
WHO: ${{ inputs.who-to-greet }}
50+
list: ${{ steps.list.outputs.json }}
51+
shell: bash
52+
- id: windows
53+
run: |
54+
json=$(echo ${list} | jq -c 'map(select(startswith("windows-") and (endswith("-latest") | not)))')
55+
echo "json=${json}" >> $GITHUB_OUTPUT
56+
env:
57+
list: ${{ steps.list.outputs.json }}
58+
shell: bash
59+
- id: macos
60+
run: |
61+
json=$(echo ${list} | jq -c 'map(select(startswith("macos-") and (endswith("-latest") | not)))')
62+
echo "json=${json}" >> $GITHUB_OUTPUT
63+
env:
64+
list: ${{ steps.list.outputs.json }}
65+
shell: bash

0 commit comments

Comments
 (0)