This repository was archived by the owner on Mar 12, 2026. It is now read-only.
Repository navigation
105 lines (94 loc) · 2.94 KB
/
Copy pathci-github-action.yml
File metadata and controls
105 lines (94 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: |-
CI - GitHub Action
Lint and test github action
### Usage
```yaml
name: Validate Terraform
on:
workflow_call:
permissions:
pull-requests: write
id-token: write
contents: read
jobs:
ci-terraform:
uses: cloudposse/github-actions-workflows/.github/workflows/ci-terraform.yml@main
with:
suggestions: true
filter-mode: diff_context
```
on:
workflow_call:
inputs:
organization:
description: "Repository owner organization (ex. acme for repo acme/example)"
required: false
default: ${{ github.event.repository.owner.login }}
type: string
repository:
description: "Repository name (ex. example for repo acme/example)"
required: false
default: ${{ github.event.repository.name }}
type: string
ref:
description: "The fully-formed ref of the branch or tag that triggered the workflow run"
required: false
default: ${{ github.ref }}
type: string
tests-prefix:
description: "Workflows file name prefix to run as tests"
required: false
type: string
default: 'test-*'
runs-on:
description: "Overrides job runs-on setting (json-encoded list)"
type: string
required: false
default: '["ubuntu-latest"]'
permissions:
contents: write
actions: write
jobs:
context:
runs-on: ${{ fromJSON(inputs.runs-on) }}
steps:
- name: Checkout main
uses: actions/checkout@v4
- name: Workflows
id: workflows
shell: bash
run: |
TEST_FILES=$(find ./.github/workflows -type f -name "${{ inputs.tests-prefix }}" -exec basename {} \; | jq -MRc -s '. | split("\n") | map(select(. != ""))')
echo "list=${TEST_FILES}" >> $GITHUB_OUTPUT
outputs:
tests: ${{ steps.workflows.outputs.list }}
lint:
runs-on: ${{ fromJSON(inputs.runs-on) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: YAML file validation
uses: mpoc/nexus-validate-using-remote-schema-action@main
with:
api-endpoint: https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-action.json
yaml-file: action.yml
test:
runs-on: ${{ fromJSON(inputs.runs-on) }}
if: ${{ needs.context.outputs.tests != '[]' }}
strategy:
matrix:
env: ${{ fromJson(needs.context.outputs.tests) }}
needs: [ lint, context ]
steps:
- uses: convictional/trigger-workflow-and-wait@v1.6.5
with:
owner: ${{ inputs.organization }}
repo: ${{ inputs.repository }}
github_token: ${{ github.token }}
workflow_file_name: ${{ matrix.env }}
ref: ${{ inputs.ref }}
wait_interval: 10
client_payload: '{}'
propagate_failure: true
trigger_workflow: true
wait_workflow: true