Skip to content

Commit

Permalink
Update URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman committed Dec 10, 2024
1 parent 15d1ea7 commit 91aabb9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions migrate/lib/readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# The first implementation attempted to use `yq` to parse the YAML file and update the badges section.
# Unfortunately, yq loses whitespace, and rewrites any multi-line strings and quoted strings.
# This caused the README.yaml to be reformatted and lose its original structure, which is not acceptable.
# It turns out that many YAML processors (especially based on Go) do not properly handle whitespace,
# comments, and multi-line strings in YAML.
# It turns out that many YAML processors (especially based on Go) do not properly handle whitespace,
# comments, and multi-line strings in YAML.
# - https://github.com/mikefarah/yq/discussions/1584
# - https://github.com/go-yaml/yaml/issues/827
#
#

import sys
import os
Expand Down Expand Up @@ -46,13 +46,13 @@ def migrate_readme(readme_yaml="README.yaml"):
return

for data in documents:

github_repo = data.get('github_repo', None)
if not github_repo or github_repo == "None":
if 'GITHUB_REPO' in os.environ:
data['github_repo'] = os.environ['GITHUB_REPO']
github_repo = data['github_repo']
else:
else:
print(f"github_repo is not set in the {readme_yaml} file.")
pass

Expand All @@ -69,7 +69,7 @@ def migrate_readme(readme_yaml="README.yaml"):
new_badges = [
{"name": "Latest Release", "image": f"https://img.shields.io/github/release/{github_repo}.svg?style=for-the-badge", "url": f"https://github.com/{github_repo}/releases/latest"},
{"name": "Last Updated", "image": f"https://img.shields.io/github/last-commit/{github_repo}.svg?style=for-the-badge", "url": f"https://github.com/{github_repo}/commits"},
{"name": "Slack Community", "image": "https://slack.cloudposse.com/for-the-badge.svg", "url": "https://slack.cloudposse.com"}
{"name": "Slack Community", "image": "https://slack.cloudposse.com/for-the-badge.svg", "url": "https://cloudposse.com/slack"}
]

# Add badges for specific workflow files if they exist
Expand All @@ -88,7 +88,7 @@ def migrate_readme(readme_yaml="README.yaml"):
data['contributors'] = []

add_newlines_before_comments(data)

# Write back the updated YAML with multiple documents
with open(readme_yaml, 'w') as file:
yaml.dump_all(documents, file)
Expand Down
4 changes: 2 additions & 2 deletions migrate/migrations/20240302/test-badges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ badges:

- name: "Slack Community"
image: "https://slack.cloudposse.com/for-the-badge.svg"
url: "https://slack.cloudposse.com"
url: "https://cloudposse.com/slack"

- name: "Slack Community"
image: https://slack.cloudposse.com/for-the-badge.svg
url: https://slack.cloudposse.com
url: https://cloudposse.com/slack

- name: "Unique Badge"
image: https://foobar.com/badge.svg
Expand Down
2 changes: 1 addition & 1 deletion profile/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Banner](https://github.com/cloudposse/.github/blob/main/profile/banner/image.png?raw=true)](https://cpco.io/homepage)
<p align="right">
<a href="https://slack.cloudposse.com" title="Slack Community"><img src="https://slack.cloudposse.com/for-the-badge.svg" alt="Slack Community"></a>
<a href="https://cloudposse.com/slack" title="Slack Community"><img src="https://slack.cloudposse.com/for-the-badge.svg" alt="Slack Community"></a>
<a href="https://cloudposse.com/office-hours/" title="Office Hours"><img src="https://img.shields.io/badge/Office_Hours-2891E8.svg?style=for-the-badge" alt="Office Hours"></a>
<a href="https://cloudposse.com/quiz/" title="Request Quote"><img src="https://img.shields.io/badge/Request_Quote-success.svg?style=for-the-badge" alt="Request Quote"></a>
</p>
Expand Down

0 comments on commit 91aabb9

Please sign in to comment.