Skip to content

Commit

Permalink
ci: warn about incorrect outgoing links (#141)
Browse files Browse the repository at this point in the history
* feat: detect bad outgoing links

* chore: fix `tput` warnings

* chore: strip trailing whitespace

* fix: incorrect links to Control Plane

* chore: use checkout@v3 instead of v2
  • Loading branch information
samueldemoura authored Mar 1, 2024
1 parent 10709a9 commit db41689
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 7 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/check_cpln_links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check Links

on:
push:
branches:
- main
pull_request:

jobs:
check_cpln_links:
runs-on: ubuntu-latest
name: Check Links
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Validate outgoing links to Control Plane
run: |
TERM=xterm-color ./script/check_cpln_links
shell: bash
3 changes: 3 additions & 0 deletions .overcommit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
PreCommit:
ValidateLinks:
enabled: true
command: ["bash", "./script/check_cpln_links"]
CommandDocs:
enabled: true
command: ["bundle", "exec", "rake", "check_command_docs"]
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The power of Kubernetes with the ease of Heroku!
# The power of Kubernetes with the ease of Heroku!

<meta name="author" content="Justin Gordon and Sergey Tarasov">
<meta name="description" content="Instructions on how to migrate from Heroku to Control Plane and a CLI called cpl to make it easier.">
Expand All @@ -12,16 +12,16 @@
[![Gem](https://badge.fury.io/rb/cpl.svg)](https://badge.fury.io/rb/cpl)


Here's a playbook for migrating from [Heroku Flow](https://www.heroku.com/flow) to [Control Plane](https://controlplane.com/shakacode) with our `cpl` gem source code.
Here's a playbook for migrating from [Heroku Flow](https://www.heroku.com/flow) to [Control Plane](https://shakacode.controlplane.com) with our `cpl` gem source code.

----

_If you need a free demo account for Control Plane (no CC required), you can contact [Justin Gordon, CEO of ShakaCode](mailto:justin@shakacode.com)._

---

Be sure to see the [demo app](https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/.controlplane)
If you would like to see the simple YAML configuration and setup,
Be sure to see the [demo app](https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/.controlplane)
If you would like to see the simple YAML configuration and setup,
Also, check [how the `cpl` gem (this project) is used in the Github actions](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.github/actions/deploy-to-control-plane/action.yml).
Here is a brief [video overview](https://www.youtube.com/watch?v=llaQoAV_6Iw).

Expand Down Expand Up @@ -125,7 +125,7 @@ npm update -g @controlplane/cli

5. Run `cpln image docker-login --org <your-org>` to ensure that you have access to the Control Plane Docker registry.

6. Install Heroku to Control Plane `cpl` CLI as a [Ruby gem](https://rubygems.org/gems/cpl): `gem install cpl`. If you want to hack on the source code, see [CONTRIBUTING.md](CONTRIBUTING.md).
6. Install Heroku to Control Plane `cpl` CLI as a [Ruby gem](https://rubygems.org/gems/cpl): `gem install cpl`. If you want to hack on the source code, see [CONTRIBUTING.md](CONTRIBUTING.md).

7. You can use [this Dockerfile](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/Dockerfile) as an example for your project. Ensure that you have Docker running.

Expand Down Expand Up @@ -493,7 +493,7 @@ cpl --help
- See [how the `cpl` gem is used in the Github actions](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.github/actions/deploy-to-control-plane/action.yml).
- Here is a brief [video overview](https://www.youtube.com/watch?v=llaQoAV_6Iw).

## Resources
## Resources
* If you need a free demo account for Control Plane (no CC required), you can contact [Justin Gordon, CEO of ShakaCode](mailto:justin@shakacode.com).
* [Control Plane Site](https://controlplane.com/shakacode)
* [Control Plane Site](https://shakacode.controlplane.com)
* [Join our Slack to Discuss Heroku to Control Plane](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE)
45 changes: 45 additions & 0 deletions script/check_cpln_links
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

bad_links=("controlplane.com/shakacode")
proper_links=("shakacode.controlplane.com")

bold=$(tput bold)
normal=$(tput sgr0)

exit_status=0
accumulated_results=""
seen_bad_links_indexes=()

for ((idx = 0; idx < ${#bad_links[@]}; idx++)); do
results=$(git grep \
--recursive \
--line-number \
--fixed-strings \
--break \
--heading \
--color=always -- \
"${bad_links[idx]}" \
':!script/check_cpln_links')

# Line would become really unwieldly if everything was mushed into the
# conditional, so let's ignore this check here.
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
accumulated_results+="$results"
seen_bad_links_indexes+=("$idx")
exit_status=1
fi
done

if [ "$exit_status" -eq 1 ]; then
echo "${bold}[!] Found the following bad links:${normal}"
echo ""
echo "$accumulated_results"
echo ""
echo "${bold}[*] Please update accordingly:${normal}"
for bad_link_index in "${seen_bad_links_indexes[@]}"; do
echo " ${bad_links[bad_link_index]} -> ${proper_links[bad_link_index]}"
done
fi

exit "$exit_status"

0 comments on commit db41689

Please sign in to comment.