-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (51 loc) · 2.18 KB
/
Copy pathpr-collection-build.yaml
File metadata and controls
56 lines (51 loc) · 2.18 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
name: PR Collection Build
on:
pull_request:
types:
- opened
- reopened
paths:
- 'collections/**'
jobs:
Analyze-Collection-Config:
container:
image: ghcr.io/stuttgart-things/github.com/stuttgart-things/machineshop:v2.6.13
environment: k8s
outputs:
collection_folders: ${{ steps.changed-files.outputs.collection_folders }}
runs-on: ghr-ansible-in-cluster
steps:
- name: Get Modified Files by PullRequest
id: changed-files
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
FILES=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"${{ github.event.pull_request.url }}/files" | \
jq -r '.[].filename')
echo "ALL_CHANGED_FILES=${FILES}"
ALL_CHANGED_FOLDERS=$(echo "$FILES" | tr ' ' '\n' | while read file; do dirname "$file"; done | sort | uniq | paste -sd ',')
ALL_CHANGED_FOLDERS=$(echo "$ALL_CHANGED_FOLDERS" | tr ',' '\n' | grep '^collections/' | tr '\n' ',')
# Remove trailing comma if present
ALL_CHANGED_FOLDERS=${ALL_CHANGED_FOLDERS%,}
echo "ALL_CHANGED_FOLDERS=${ALL_CHANGED_FOLDERS}"
# SET CHANGED_FOLDERS AS MATRIX JSON
tf_folders=$(echo "\"${ALL_CHANGED_FOLDERS}\"" | sed 's/,/", "/g')
JSON_FOLDERS='{ "collection-directory": ['"${tf_folders}"'] }'
echo ${JSON_FOLDERS}
echo "collection_folders=${JSON_FOLDERS}" >> "$GITHUB_OUTPUT"
Build-Collections:
needs: Analyze-Collection-Config
if: ${{ needs.Analyze-Collection-Config.outputs.collection_folders != '[]' && needs.Analyze-Collection-Config.outputs.collection_folders != '' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.Analyze-Collection-Config.outputs.collection_folders) }}
uses: stuttgart-things/github-workflow-templates/.github/workflows/call-ansible-collection.yaml@main
with:
runs-on: ubuntu-latest
environment-name: k8s
collection-directory: ${{ matrix.collection-directory }}
dagger-module-version: v0.109.0
dagger-version: v0.20.6
branch-name: ${{ github.event.pull_request.head.ref }}
secrets: inherit # pragma: allowlist secret