-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (80 loc) · 2.92 KB
/
update-repo-request-template.yml
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
name: Update the 'Repo-Request' Issue Template
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *" # every night at midnight to update teams
push:
paths:
- "./templates/languages/**"
- ".github/workflows/update-repo-request-template.yml"
permissions:
contents: write
env:
REPO_REQUEST_FILE: .github/ISSUE_TEMPLATE/repo-request.yml
REPO_REQUEST_TEMPLATE_FILE: .github/ISSUE_TEMPLATE/repo-request-template.yml
jobs:
update-org:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Token
id: get-workflow-token
uses: peter-murray/workflow-application-token-action@v2
with:
application_id: ${{ vars.GH_APP_ID }}
application_private_key: ${{ secrets.GH_APP_KEY }}
organization: ${{ vars.ORGANIZATION }}
- name: Get Teams
uses: ./.github/actions/get-teams
id: get-teams
with:
token: ${{ steps.get-workflow-token.outputs.token }}
organization: ${{ vars.ORGANIZATION }}
- name: Update Teams
env:
JSON: ${{ steps.get-teams.outputs.json }}
run: |
TEAMS=$( echo $JSON \
| jq -r '.[] | "- " + .name + (.description | if . == "" then . else " - " + . end)' \
| sort ) \
yq -i '(.body[] | select(.type=="dropdown" and .attributes.label=="Team") | .attributes.options) |=env(TEAMS)' \
$REPO_REQUEST_FILE
- name: Update Languages
run: |
LANGUAGES=$( find ./templates/languages \
-mindepth 1 \
-maxdepth 1 \
-type d \
-exec sh \
-c 'echo - $(basename "$1")' sh {} \; \
| sort ) \
yq -i '(.body[] | select(.type=="dropdown" and .attributes.label=="Language") | .attributes.options) |=env(LANGUAGES)' \
$REPO_REQUEST_FILE
- name: Determine Changes
id: change-detection
run: |
if (git diff --quiet $REPO_REQUEST_FILE)
then
echo changed=false >> "$GITHUB_OUTPUT"
else
echo changed=true >> "$GITHUB_OUTPUT"
fi
- name: Display File
if: ${{ steps.change-detection.outputs.changed == 'true' }}
run: cat $REPO_REQUEST_FILE
- name: "Yamllint"
if: ${{ steps.change-detection.outputs.changed == 'true' }}
uses: karancode/yamllint-github-action@master
with:
yamllint_file_or_dir: ${{ env.REPO_REQUEST_FILE }}
yamllint_strict: true
- name: Commit Changes
if: ${{ steps.change-detection.outputs.changed == 'true' }}
env:
CI_COMMIT_MESSAGE: "chore(org): Update Issue Template File"
run: |
git config --global user.name '${{ vars.CI_COMMIT_USER }}'
git config --global user.email '${{ vars.CI_COMMIT_USER_MAIL }}'
git add $REPO_REQUEST_FILE
git commit -m "$CI_COMMIT_MESSAGE"
git push