Skip to content

Commit 7364b72

Browse files
authored
Added github action docs (#327)
## what * Added Github action docs ## why * Generated README docs from `action.yaml`
1 parent 3886417 commit 7364b72

File tree

8 files changed

+71
-37
lines changed

8 files changed

+71
-37
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ RUN apk --update --no-cache add \
3131
boto==2.49.0 \
3232
boto3==1.21.1 \
3333
iteration-utilities==0.11.0 \
34-
pre-commit \
3534
PyGithub==1.55 && \
3635
git config --global advice.detachedHead false
3736

37+
## Workaround https://github.com/pypa/pip/issues/5247
38+
RUN pip3 install --upgrade --force-reinstall pip==9.0.3 && \
39+
pip3 install --no-cache-dir --disable-pip-version-check pre-commit && \
40+
pip3 install --upgrade pip
41+
3842
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
3943
RUN curl -fsSL --retry 3 https://apk.cloudposse.com/install.sh | bash
4044

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ It's designed to work with CI/CD systems such as GitHub Actions, Codefresh, Trav
3434
## Regarding the phase out of `git.io`
3535

3636
Prior to April 25, 2022, practically all Cloud Posse Makefiles pulled in a common Makefile via
37-
```
37+
```bash
3838
curl -sSL -o .build-harness "https://git.io/build-harness"
3939
```
4040

@@ -182,6 +182,7 @@ Available targets:
182182
docker/image/push Push $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
183183
docker/login Login into docker hub
184184
docs/copyright-add Add copyright headers to source code
185+
docs/github-action.md Update `docs/github-action.md` from `action.yaml`
185186
docs/targets.md Update `docs/targets.md` from `make help`
186187
docs/terraform.md Update `docs/terraform.md` from `terraform-docs`
187188
geodesic/deploy Run a Jenkins Job to Deploy $(APP) with $(CANONICAL_TAG)
@@ -323,7 +324,7 @@ Available targets:
323324
<!-- markdownlint-restore -->
324325
# GIT.IO DEPRECATION
325326

326-
On April 25, 2022, GitHub announced that the [`git.io` redirector service would be shutting down on 2022-04-29](https://github.blog/changelog/2022-04-25-git-io-deprecation/), merely 4 days later. The announcement said that all references to `git.io`
327+
On April 25, 2022, GitHub announced that the [`git.io` redirector service would be shutting down on 2022-04-29](https://github.blog/changelog/2022-04-25-git-io-deprecation/), merely 4 days later. The announcement said that all references to `git.io`
327328
would stop working that day.
328329

329330
This was a major breaking change for Cloud Posse, because *all* of our standard Makefiles include a Makefile from this `build-harness`
@@ -335,21 +336,21 @@ and undertook an emergency update of all of our repositories to make this change
335336

336337
While we were largely successful in updating our repositories by 2022-04-29, Cloud Posse was not fully prepared to make the
337338
mass updates across all of our repositories that this required, so some repositories were not updated in time. Furthermore,
338-
even if all of Cloud Posse's repositories were updated, that would not affect anyone's fork or clone or
339+
even if all of Cloud Posse's repositories were updated, that would not affect anyone's fork or clone or
339340
locally checked-out version, so we are publishing the instructions below to help you update your own code.
340341

341342
Fortunately, GitHub recognized the massive upheaval and loss that would be caused by completely shutting down
342343
an URL shorting/link redirecting service, and reversed their decision to shut down `git.io` completely. Instead,
343344
they agreed to archive the links and continue to serve existing links indefinitely, with the caveat that they
344-
would remove links on a case-by-case basis if they were found to be malicious, misleading, or broken.
345+
would remove links on a case-by-case basis if they were found to be malicious, misleading, or broken.
345346

346347
This means that instead of being an urgent requirement that you immediately change your links, or else your builds would break,
347-
it is now merely a recommended best practice that you update to the new link that Cloud Posse controls and
348-
is committed to maintaining.
348+
it is now merely a recommended best practice that you update to the new link that Cloud Posse controls and
349+
is committed to maintaining.
349350

350351
Specifically, in source files you control, you should update all references to `git.io/build-harness`
351-
to instead refer to `cloudposse.tools/build-harness`. Critical references are in Makefiles, and there are also
352-
important references in README files that describe Makefiles. References in derived or downloaded files, such as
352+
to instead refer to `cloudposse.tools/build-harness`. Critical references are in Makefiles, and there are also
353+
important references in README files that describe Makefiles. References in derived or downloaded files, such as
353354
Terraform modules downloaded by `terraform init`, do not need to be modified.
354355
Below we provide guidance on how to make the replacements.
355356

@@ -362,44 +363,44 @@ or a `src` (or similar) directory under which you have all your `git` repos (dir
362363
### Finding affected files
363364

364365
Use the following command to find all occurrences in all directories recursively:
365-
```
366+
```bash
366367
grep -l "git\.io/build-harness" -R .
367368
```
368369
Note that the above command can reach very deeply, such as into Terraform modules you have downloaded. You may want to impose some limits.
369370
If you run from the top level of a `git` repo, where there is a `Makefile` and a `Dockerfile`, you can reduce that to
370-
```
371+
```bash
371372
grep -l "git\.io/build-harness" *
372373
```
373374
If you have a lot of Cloud Posse projects under a single directory, then you might try
374-
```
375+
```bash
375376
grep -l "git\.io/build-harness" * */*
376377
```
377378
or for full depth below the current directory
378-
```
379+
```bash
379380
find . \( -name .terraform -prune -type f \) -o \( -name build-harness -prune -type f \) -o \( -name 'Makefile*' -o -name 'README*' \) -type f
380381
```
381382

382383
### Updating the affected files
383384

384385
Once you are happy with the command to generate the list of files to update, update the files by inserting that command into this command template:
385-
```
386+
```bash
386387
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(<command to list files>)
387388
```
388389

389-
#### Examples
390+
#### Samples
390391

391392
The quickest update will be if you only have a single project to update, in which case you can `cd` into the project root directory and
392-
```
393+
```bash
393394
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(grep -l "git\.io/build-harness" *)
394395
```
395396

396397
If you have multiple projects to update and want to be thorough, then this is probably best:
397-
```
398+
```bash
398399
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(find . \( -name .terraform -prune -type f \) -o \( -name build-harness -prune -type f \) -o \( -name 'Makefile*' -o -name 'README*' \) -type f )
399400
```
400401

401402
This is the most thorough, but probably overkill for most people:
402-
```
403+
```bash
403404
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(grep -l "git\.io/build-harness" -R .)
404405
```
405406

@@ -582,7 +583,7 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
582583

583584
[![README Footer][readme_footer_img]][readme_footer_link]
584585
[![Beacon][beacon]][website]
585-
586+
<!-- markdownlint-disable -->
586587
[logo]: https://cloudposse.com/logo-300x69.svg
587588
[docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/build-harness&utm_content=docs
588589
[website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/build-harness&utm_content=website
@@ -613,3 +614,4 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
613614
[share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/build-harness
614615
[share_email]: mailto:?subject=Build+Harness&body=https://github.com/cloudposse/build-harness
615616
[beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/build-harness?pixel&cs=github&cm=readme&an=build-harness
617+
<!-- markdownlint-restore -->

README.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ description: |-
6464
## Regarding the phase out of `git.io`
6565
6666
Prior to April 25, 2022, practically all Cloud Posse Makefiles pulled in a common Makefile via
67-
```
67+
```bash
6868
curl -sSL -o .build-harness "https://git.io/build-harness"
6969
```
7070

docs/git-io-deprecation.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GIT.IO DEPRECATION
22

3-
On April 25, 2022, GitHub announced that the [`git.io` redirector service would be shutting down on 2022-04-29](https://github.blog/changelog/2022-04-25-git-io-deprecation/), merely 4 days later. The announcement said that all references to `git.io`
3+
On April 25, 2022, GitHub announced that the [`git.io` redirector service would be shutting down on 2022-04-29](https://github.blog/changelog/2022-04-25-git-io-deprecation/), merely 4 days later. The announcement said that all references to `git.io`
44
would stop working that day.
55

66
This was a major breaking change for Cloud Posse, because *all* of our standard Makefiles include a Makefile from this `build-harness`
@@ -12,21 +12,21 @@ and undertook an emergency update of all of our repositories to make this change
1212

1313
While we were largely successful in updating our repositories by 2022-04-29, Cloud Posse was not fully prepared to make the
1414
mass updates across all of our repositories that this required, so some repositories were not updated in time. Furthermore,
15-
even if all of Cloud Posse's repositories were updated, that would not affect anyone's fork or clone or
15+
even if all of Cloud Posse's repositories were updated, that would not affect anyone's fork or clone or
1616
locally checked-out version, so we are publishing the instructions below to help you update your own code.
1717

1818
Fortunately, GitHub recognized the massive upheaval and loss that would be caused by completely shutting down
1919
an URL shorting/link redirecting service, and reversed their decision to shut down `git.io` completely. Instead,
2020
they agreed to archive the links and continue to serve existing links indefinitely, with the caveat that they
21-
would remove links on a case-by-case basis if they were found to be malicious, misleading, or broken.
21+
would remove links on a case-by-case basis if they were found to be malicious, misleading, or broken.
2222

2323
This means that instead of being an urgent requirement that you immediately change your links, or else your builds would break,
24-
it is now merely a recommended best practice that you update to the new link that Cloud Posse controls and
25-
is committed to maintaining.
24+
it is now merely a recommended best practice that you update to the new link that Cloud Posse controls and
25+
is committed to maintaining.
2626

2727
Specifically, in source files you control, you should update all references to `git.io/build-harness`
28-
to instead refer to `cloudposse.tools/build-harness`. Critical references are in Makefiles, and there are also
29-
important references in README files that describe Makefiles. References in derived or downloaded files, such as
28+
to instead refer to `cloudposse.tools/build-harness`. Critical references are in Makefiles, and there are also
29+
important references in README files that describe Makefiles. References in derived or downloaded files, such as
3030
Terraform modules downloaded by `terraform init`, do not need to be modified.
3131
Below we provide guidance on how to make the replacements.
3232

@@ -39,44 +39,44 @@ or a `src` (or similar) directory under which you have all your `git` repos (dir
3939
### Finding affected files
4040

4141
Use the following command to find all occurrences in all directories recursively:
42-
```
42+
```bash
4343
grep -l "git\.io/build-harness" -R .
4444
```
4545
Note that the above command can reach very deeply, such as into Terraform modules you have downloaded. You may want to impose some limits.
4646
If you run from the top level of a `git` repo, where there is a `Makefile` and a `Dockerfile`, you can reduce that to
47-
```
47+
```bash
4848
grep -l "git\.io/build-harness" *
4949
```
5050
If you have a lot of Cloud Posse projects under a single directory, then you might try
51-
```
51+
```bash
5252
grep -l "git\.io/build-harness" * */*
5353
```
5454
or for full depth below the current directory
55-
```
55+
```bash
5656
find . \( -name .terraform -prune -type f \) -o \( -name build-harness -prune -type f \) -o \( -name 'Makefile*' -o -name 'README*' \) -type f
5757
```
5858

5959
### Updating the affected files
6060

6161
Once you are happy with the command to generate the list of files to update, update the files by inserting that command into this command template:
62-
```
62+
```bash
6363
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(<command to list files>)
6464
```
6565

66-
#### Examples
66+
#### Samples
6767

6868
The quickest update will be if you only have a single project to update, in which case you can `cd` into the project root directory and
69-
```
69+
```bash
7070
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(grep -l "git\.io/build-harness" *)
7171
```
7272

7373
If you have multiple projects to update and want to be thorough, then this is probably best:
74-
```
74+
```bash
7575
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(find . \( -name .terraform -prune -type f \) -o \( -name build-harness -prune -type f \) -o \( -name 'Makefile*' -o -name 'README*' \) -type f )
7676
```
7777

7878
This is the most thorough, but probably overkill for most people:
79-
```
79+
```bash
8080
sed -i '' 's/git.io\/build-harness/cloudposse.tools\/build-harness/' $(grep -l "git\.io/build-harness" -R .)
8181
```
8282

docs/targets.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Available targets:
4343
docker/image/push Push $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
4444
docker/login Login into docker hub
4545
docs/copyright-add Add copyright headers to source code
46+
docs/github-action.md Update `docs/github-action.md` from `action.yaml`
4647
docs/targets.md Update `docs/targets.md` from `make help`
4748
docs/terraform.md Update `docs/terraform.md` from `terraform-docs`
4849
geodesic/deploy Run a Jenkins Job to Deploy $(APP) with $(CANONICAL_TAG)

modules/docs/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ docs/terraform.md: docs/deps packages/install/terraform-docs
2020
@echo "<!-- markdownlint-disable -->" > $@
2121
@terraform-docs md . >> $@
2222
@echo "<!-- markdownlint-restore -->" >> $@
23+
24+
.PHONY : docs/github-action.md
25+
## Update `docs/github-action.md` from `action.yaml`
26+
docs/github-action.md: docs/deps packages/install/gomplate
27+
@echo "<!-- markdownlint-disable -->" > $@
28+
@gomplate -d action=./action.yml -f $(BUILD_HARNESS_PATH)/templates/docs-github-action.gotmpl >> $@
29+
@echo "<!-- markdownlint-restore -->" >> $@

templates/README.md.gotmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
448448
449449
[![README Footer][readme_footer_img]][readme_footer_link]
450450
[![Beacon][beacon]][website]
451-
451+
<!-- markdownlint-disable -->
452452
[logo]: https://cloudposse.com/logo-300x69.svg
453453
[docs]: {{ printf $utm_link "https://cpco.io/docs" "docs" }}
454454
[website]: {{ printf $utm_link "https://cpco.io/homepage" "website" }}
@@ -479,3 +479,4 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
479479
[share_googleplus]: {{ printf "https://plus.google.com/share?url=https://github.com/%s" (ds "config").github_repo }}
480480
[share_email]: {{ printf "mailto:?subject=%s&body=https://github.com/%s" ((ds "config").name | regexp.Replace " " "+") (ds "config").github_repo }}
481481
[beacon]: {{ printf "https://ga-beacon.cloudposse.com/UA-76589703-4/%s?pixel&cs=github&cm=readme&an=%s" (ds "config").github_repo (filepath.Base ((ds "config").github_repo)) }}
482+
<!-- markdownlint-restore -->
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{/* Inspired https://github.com/Dirrk/action-docs/blob/master/src/default_template.tpl */}}
2+
{{- define "escape_chars" }}{{ . | strings.ReplaceAll "_" "\\_" | strings.ReplaceAll "|" "\\|" | strings.ReplaceAll "*" "\\*" }}{{- end }}
3+
{{- define "sanatize_string" }}{{ . | strings.ReplaceAll "\n\n" "<br><br>" | strings.ReplaceAll " \n" "<br>" | strings.ReplaceAll "\n" "<br>" | tmpl.Exec "escape_chars" }}{{- end }}
4+
{{- $action := (datasource "action") -}}
5+
## Inputs
6+
7+
| Name | Description | Default | Required |
8+
|------|-------------|---------|----------|
9+
{{- range $key, $input := $action.inputs }}
10+
| {{ tmpl.Exec "escape_chars" $key }} | {{ if (has $input "description") }}{{ tmpl.Exec "sanatize_string" $input.description }}{{ else }}{{ tmpl.Exec "escape_chars" $key }}{{ end }} | {{ if (has $input "default") }}{{ tmpl.Exec "sanatize_string" $input.default }}{{ else }}N/A{{ end }} | {{ if (has $input "required") }}{{ $input.required }}{{ else }}false{{ end }} |
11+
{{- end }}
12+
13+
## Outputs
14+
15+
| Name | Description |
16+
|------|-------------|
17+
{{- range $key, $output := $action.outputs }}
18+
| {{ tmpl.Exec "escape_chars" $key }} | {{ if (has $output "description") }}{{ tmpl.Exec "sanatize_string" $output.description }}{{ else }}{{ tmpl.Exec "escape_chars" $key }}{{ end }} |
19+
{{- end }}

0 commit comments

Comments
 (0)