Skip to content

Commit edc2fd7

Browse files
authored
Merge pull request #104 from itk-dev/feature/github-actions-templates
Added GitHub Actions templates and tool configuration files
2 parents 2987008 + 26ebf6a commit edc2fd7

File tree

177 files changed

+2161
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+2161
-80
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
on: pull_request
2+
3+
name: Review
4+
5+
env:
6+
COMPOSE_USER: runner
7+
8+
jobs:
9+
check-github-actions-documentation:
10+
runs-on: ubuntu-latest
11+
name: Check that Github Actions documentation is up to date
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: arduino/setup-task@v2
15+
# https://github.com/arduino/setup-task/tree/56d0cc033e3cecc5f07a291fdd39f29388d21800?tab=readme-ov-file#repo-token
16+
with:
17+
repo-token: ${{ secrets.GITHUB_TOKEN }}
18+
19+
# https://github.com/mxschmitt/action-tmate?tab=readme-ov-file#manually-triggered-debug
20+
# Enable tmate debugging if debug logging is enabled (cf.
21+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#runner-context)
22+
- name: Setup tmate session
23+
uses: mxschmitt/action-tmate@v3
24+
if: 1 == runner.debug
25+
26+
- run: |
27+
task github-actions:documentation:update
28+
29+
# Check that documentation has not changed.
30+
- run: |
31+
task github-actions:documentation:diff
32+
33+
check-github-actions-template-headers:
34+
runs-on: ubuntu-latest
35+
name: Check that Github Actions template headers are up to date
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: arduino/setup-task@v2
39+
with:
40+
repo-token: ${{ secrets.GITHUB_TOKEN }}
41+
- run: |
42+
task github-actions:template-headers:update --yes
43+
# Check that files have not changed.
44+
- run: |
45+
git diff --exit-code
46+
47+
check-config-file-headers:
48+
runs-on: ubuntu-latest
49+
name: Check that config file headers are up to date
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: arduino/setup-task@v2
53+
with:
54+
repo-token: ${{ secrets.GITHUB_TOKEN }}
55+
- run: |
56+
task github-actions:config-headers:update --yes
57+
# Check that files have not changed.
58+
- run: |
59+
git diff --exit-code
60+
61+
check-links:
62+
runs-on: ubuntu-latest
63+
name: Check that workflow and config file links are up to date
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: arduino/setup-task@v2
67+
with:
68+
repo-token: ${{ secrets.GITHUB_TOKEN }}
69+
- run: |
70+
task github-actions:link --yes
71+
# Check that files have not changed.
72+
- run: |
73+
git diff --exit-code
74+
75+
lint-markdown:
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v4
79+
- uses: arduino/setup-task@v2
80+
with:
81+
repo-token: ${{ secrets.GITHUB_TOKEN }}
82+
- run: |
83+
SKIP_FIX=1 task lint:markdown
84+
85+
lint-shell-script:
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
- uses: arduino/setup-task@v2
90+
with:
91+
repo-token: ${{ secrets.GITHUB_TOKEN }}
92+
- run: |
93+
SKIP_FIX=1 task lint:shell-script

.github/workflows/markdown.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Do not edit this file! Make a pull request on changing
2+
# github/workflows/markdown.yaml in
3+
# https://github.com/itk-dev/devops_itkdev-docker if need be.
4+
5+
### ### Markdown
6+
###
7+
### Lints Markdown files (`**/*.md`) in the project.
8+
###
9+
### [markdownlint-cli configuration
10+
### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration),
11+
### `.markdownlint.jsonc` and `.markdownlintignore`, control what is actually
12+
### linted and how.
13+
###
14+
### #### Assumptions
15+
###
16+
### 1. A docker compose service named `markdownlint` for running `markdownlint`
17+
### (from
18+
### [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli))
19+
### exists.
20+
21+
name: Markdown
22+
23+
on:
24+
pull_request:
25+
push:
26+
branches:
27+
- main
28+
- develop
29+
30+
jobs:
31+
markdown-lint:
32+
runs-on: ubuntu-latest
33+
strategy:
34+
fail-fast: false
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- run: |
40+
docker network create frontend
41+
42+
- run: |
43+
docker compose run --rm markdownlint markdownlint '**/*.md'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on: pull_request
2+
3+
name: Workflow templates
4+
5+
jobs:
6+
check-yaml:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- run: |
12+
docker pull mikefarah/yq
13+
for f in $(find github/workflows/ -name '*.yaml'); do
14+
docker run --rm --volume "$PWD":/workdir mikefarah/yq "$f" > /dev/null
15+
done
16+
17+
shellcheck:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: arduino/setup-task@v2
22+
with:
23+
repo-token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- run: |
26+
task lint:shell-script

.github/workflows/yaml.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Do not edit this file! Make a pull request on changing
2+
# github/workflows/yaml.yaml in
3+
# https://github.com/itk-dev/devops_itkdev-docker if need be.
4+
5+
### ### YAML
6+
###
7+
### Validates YAML files.
8+
###
9+
### #### Assumptions
10+
###
11+
### 1. A docker compose service named `prettier` for running
12+
### [Prettier](https://prettier.io/) exists.
13+
###
14+
### #### Symfony YAML
15+
###
16+
### Symfony's YAML config files use 4 spaces for indentation and single quotes.
17+
### Therefore we use a [Prettier configuration
18+
### file](https://prettier.io/docs/configuration), `.prettierrc.yaml`, to make
19+
### Prettier format YAML files in the `config/` folder like Symfony expects.
20+
21+
name: YAML
22+
23+
on:
24+
pull_request:
25+
push:
26+
branches:
27+
- main
28+
- develop
29+
30+
jobs:
31+
yaml-lint:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- run: |
37+
docker network create frontend
38+
39+
- run: |
40+
docker compose run --rm prettier '**/*.{yml,yaml}' --check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.task

.markdownlint.jsonc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// markdownlint-cli configuration file (cf. https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration)
2+
{
3+
"default": true,
4+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
5+
"line-length": {
6+
"line_length": 120,
7+
"code_blocks": false,
8+
"tables": false
9+
},
10+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
11+
"no-duplicate-heading": {
12+
"siblings_only": true
13+
},
14+
// https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections#creating-a-collapsed-section
15+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md
16+
"no-inline-html": {
17+
"allowed_elements": ["details", "summary"]
18+
}
19+
}

.markdownlintignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#ignoring-files
2+
vendor/
3+
node_modules/
4+
LICENSE.md
5+
# Drupal
6+
web/*.md
7+
web/core/
8+
web/*/contrib/

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
- [PR-108](https://github.com/itk-dev/devops_itkdev-docker/pull/108)
11+
Added Drupal module template
12+
1013
### Changed
1114

1215
- Updated to PHP 8.3

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,28 @@ __Note__: You have to follow the instructions brew writes to get it working (use
3939
If you use the [Dory](https://github.com/FreedomBen/dory) revers proxy required to
4040
run DDF CMS unmodified you need to install dory. We only use dory for DPL/DDF shared
4141
projects (multi supplier projects).
42+
4243
```sh
4344
brew install dory
4445
```
4546

4647
### Templates
4748

4849
The [`templates`](templates/) directory contains templates for adding
49-
the itkdev `docker-compose` setup to new or exiting projects.
50+
the itkdev `docker compose` setup to new or exiting projects.
51+
52+
Run
5053

5154
```sh
52-
rsync -avz templates/<TYPE>/ <PATH TO HTDOCS FOLDER>
55+
itkdev-docker-compose template:install --list
5356
```
5457

55-
Also create an `.env` file beside the `docker-compose.yml` file that contains
56-
`COMPOSE_PROJECT_NAME=<NAME>` to namespace the docker setup for the projekt.
58+
to see a list of all templates.
59+
60+
Run `itkdev-docker-compose template:install drupal-10`, say, to install or update a template in a project.
61+
62+
In addition to the docker compose setup for our projects, installing a template will also add GitHib Actions workflow
63+
files to a project; see [Github Actions templates](docs/github-actions-templates.md) for details.
5764

5865
### Docker commands
5966

@@ -112,13 +119,15 @@ LOCAL_PATH='sites/default/files'
112119

113120
## SSL certification support
114121

115-
This setup comes with self-signed wildcard certificates for *.local.itkdev.dk, but other certificates can be generated by using this openssl command on Mac, just change the two places where the domain is written.
122+
This setup comes with self-signed wildcard certificates for *.local.itkdev.dk, but other certificates can be generated
123+
by using this openssl command on Mac, just change the two places where the domain is written.
116124

117125
```sh
118126
openssl req -x509 -sha256 -nodes -days 3650 -newkey rsa:2048 -keyout docker.key -out docker.crt -subj "/CN=*.local.itkdev.dk" -reqexts SAN -extensions SAN -config <(cat /usr/local/etc/openssl/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:*.local.itkdev.dk'))
119127
```
120128

121-
To mac browser trust this certificate you need to open it with key-chain right click and select "Get info" and then open the "Trust" tab and select "Always trust".
129+
To mac browser trust this certificate you need to open it with key-chain right click and select "Get info" and then open
130+
the "Trust" tab and select "Always trust".
122131

123132
The certificate is located in `./treafik/ssl/docker.crt` in this repository.
124133

@@ -158,17 +167,19 @@ The fuld list can be found at
158167
[https://hub.docker.com/search?q=itkdev&type=image](https://hub.docker.com/search?q=itkdev&type=image).
159168

160169
## More
161-
For more details about usage see https://docs.itkdev.dk
170+
171+
For more details about usage see <https://docs.itkdev.dk>
162172

163173
## Previous versions
164174

165175
### NFS mounts removed
166176

167177
From version 3.0.0 the feature to use NFS mounted name-volumes has been removed
168-
because it is no longer compatible with MacOS. (@see https://github.com/docker/for-mac/issues/6544)
178+
because it is no longer compatible with MacOS. (@see <https://github.com/docker/for-mac/issues/6544>)
169179

170180
If you have previously enabled NFS with `nfs:enable` you should clean up as
171181
follows:
182+
172183
```shell
173184
sudo nano /etc/exports
174185
# Delete the line matching this pattern, and save you changes

Taskfile.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# https://taskfile.dev
2+
3+
version: "3"
4+
5+
includes:
6+
github-actions: ./task/Taskfile.github-actions.yml
7+
8+
vars:
9+
GITHUB_ACTIONS_TEMPLATES_HEADER: |
10+
# Github Actions templates
11+
12+
This repository contains a number of [GitHub
13+
Actions](https://docs.github.com/en/actions) workflow template files that
14+
are copied to a project when running `itkdev-docker-compose
15+
template:install`. Any changes to the workflows should be made in [this
16+
repository](%THIS_REPOSITORY%) and then the project template must be updated
17+
to match the new templates.
18+
19+
GITHUB_ACTIONS_TEMPLATES_FOOTER: |
20+
21+
tasks:
22+
build:
23+
desc: "Build everything"
24+
cmds:
25+
- task: github-actions:config-headers:update
26+
- task: github-actions:template-headers:update
27+
- task: github-actions:documentation:update
28+
- task: github-actions:link
29+
- task: lint:markdown
30+
- task: lint:yaml
31+
32+
lint:markdown:
33+
desc: "Lint Markdown"
34+
cmds:
35+
- '[[ -n "$SKIP_FIX" ]] || docker run --rm --volume "$PWD":/md itkdev/markdownlint markdownlint {{.GLOB}} --fix'
36+
- docker run --rm --volume "$PWD":/md itkdev/markdownlint markdownlint {{.GLOB}}
37+
vars:
38+
# We use a block scalar (https://yaml-multiline.info/#block-scalars) here to make escaping (a little) easier.
39+
GLOB: >-
40+
{{.CLI_ARGS | default "'**/*.md'"}}
41+
42+
lint:shell-script:
43+
desc: "Lint shell scripts"
44+
cmds:
45+
# https://github.com/koalaman/shellcheck?tab=readme-ov-file#installing
46+
- docker run --rm --volume "$PWD:"/mnt koalaman/shellcheck:stable {{.GLOB}}
47+
vars:
48+
# We use a block scalar (https://yaml-multiline.info/#block-scalars) here to make escaping (a little) easier.
49+
GLOB: >-
50+
{{.CLI_ARGS | default "task/scripts/*"}}
51+
52+
lint:yaml:
53+
desc: "Lint YAML"
54+
cmds:
55+
- |
56+
# docker pull mikefarah/yq
57+
for f in $(find github/workflows/ -name '*.yaml'); do
58+
docker run --rm --volume "$PWD":/workdir mikefarah/yq "$f" > /dev/null
59+
done
60+
61+
default:
62+
cmds:
63+
- task --list
64+
silent: true

0 commit comments

Comments
 (0)