-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (132 loc) Β· 5 KB
/
setup.yaml
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Initialize
on:
push:
workflow_dispatch:
env:
DOCS_HOME: "https://docs.crow.nl"
jobs:
setup-repo:
name: Setup repo
if: ${{ github.repository != 'Stichting-CROW/respec-repo-template' }}
runs-on: ubuntu-latest
steps:
- name: Checkout ποΈ
uses: actions/checkout@v2
with:
fetch-depth: 1 # merely the last
ref: ${{ github.head_ref }}
token: ${{ secrets.NEW_RESPEC_REPO_WORKFLOW }}
# rewriting workflows/*.yaml disallowed without Workflow-level token.
- name: Calculate document metadata π§Ύ
uses: actions/github-script@v4
id: fetch-repo-and-user-details
with:
script: |
const query = `query ($owner: String!, $name: String!, $login:String!) {
repository(owner: $owner, name: $name) {
name
description
owner {
login
... on User {
name
}
... on Organization {
name
}
}
}
user(login:$login) {
name
}
}`;
const variables = {
login: "${{ github.actor }}",
owner: context.repo.owner,
name: context.repo.repo,
}
const result = await github.graphql(query, variables)
console.log(result)
return result
- name: Calculate variables ποΈ
env:
INFO: ${{ steps.fetch-repo-and-user-details.outputs.result }}
run: |
echo "REPO_NAME=$(echo $INFO | jq -r .repository.name)" >> $GITHUB_ENV
- name: Install cookiecutter πͺ
run: pip3 install cookiecutter
- name: Add workflows π€
env:
INFO: ${{ steps.fetch-repo-and-user-details.outputs.result }}
run: |
# Run cookiecutter
pushd /tmp
cookiecutter gh:stichting-crow/respec-workflows-template --no-input
popd
# Move generated content to workflows directory of repo
mv /tmp/workflows/* .github/workflows/
- name: Add first document π©βπ³
env:
INFO: ${{ steps.fetch-repo-and-user-details.outputs.result }}
run: |
# Run cookiecutter
pushd /tmp
cookiecutter gh:stichting-crow/respec-document-template --no-input \
document_short_name="$REPO_NAME" \
repository_name="$REPO_NAME" \
document_title="$(echo $INFO | jq -r .repository.description)" \
document_type="technische documentatie" \
first_editor="$(echo $INFO | jq -r .user.name)"
popd
# Move generated content to root directory of repo
mkdir docs
mv /tmp/$REPO_NAME docs/
- name: Clean up after importing π©βπ³
env:
INFO: ${{ steps.fetch-repo-and-user-details.outputs.result }}
run: |
# Delete the setup workflow, it has served its purpose
rm .github/workflows/setup.yaml
# Replace the template README with the repo README
mv README_AFTER_CLONE.md README.md
- name: Save template version info
run: |
declare -a templates=("respec-repo-template" "respec-document-template" "respec-workflows-template")
for i in "${templates[@]}"; do
echo "stichting-crow/$i@$(\
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/stichting-crow/$i/releases/latest \
| jq -r .tag_name \
)" >> .github/VERSION
done
- name: Push new repo contents π
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: |
Initialize new ReSpec repository
Reason: run setup.yaml after clone by ${{ github.actor }}
commit_user_name: stichting-crow-klusjesbot
commit_user_email: [email protected]
push_options: --force # since this is at setup
- name: Report to log π
run: |
echo "## Werkdocument π" >> $GITHUB_STEP_SUMMARY
echo "docs/$REPO_NAME/$REPO_NAME" >> $GITHUB_STEP_SUMMARY
start-gh-pages:
name: Configure repo settings
# Put in setup.yaml, not in those from stichting-crow/respec-workflows-template, as
# that may be execute on repos that might not use gh-pages as
runs-on: ubuntu-latest
if: ${{ github.repository != 'Stichting-CROW/respec-repo-template' }}
permissions:
pages: write
steps:
- name: Set gh-pages branch and path
run: |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/pages \
-d '{"source":{"branch":"gh-pages","path":"/"}}'