Skip to content

Commit

Permalink
add banners and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman committed Jan 16, 2024
1 parent b92e5f1 commit 492b407
Show file tree
Hide file tree
Showing 17 changed files with 774 additions and 4 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/org-banner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: GitHub Org Banner

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
generate:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write

steps:
- uses: actions/checkout@v3

- name: Generate banner image
id: screenshot
uses: cloudposse-github-actions/screenshot@main
with:
url: "file://${{github.workspace}}/profile/banner/index.html"
output: "profile/banner/image.png"
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/customizing-your-repositorys-social-media-preview
viewportWidth: 1280
viewportHeight: 370
omitBackground: true

- uses: stefanzweifel/git-auto-commit-action@v4
name: Commit artifact
id: auto-commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit_message: "chore: update org banner image"
commit_user_name: screenshot-action 📷
commit_user_email: [email protected]
commit_author: screenshot-action 📷 <[email protected]>
file_pattern: 'profile/*.png'

- name: Add Image to Step Summary
if: steps.auto-commit.outputs.changes_detected == 'true'
run: |
echo "## Generated Screenshot" >> $GITHUB_STEP_SUMMARY
echo "![Generated Screenshot](https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.commit_hash }}/${{ steps.screenshot.outputs.file }}?raw=true)" >> $GITHUB_STEP_SUMMARY
- name: No changes
if: steps.auto-commit.outputs.changes_detected == 'false'
run: |
echo "No changes to screenshot" >> $GITHUB_STEP_SUMMARY
89 changes: 89 additions & 0 deletions .github/workflows/repo-banner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: GitHub Repo Banner

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
generate:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write

steps:
- uses: actions/checkout@v3

- id: metadata
uses: ahmadnassri/action-metadata@v2

- name: Determine Repo Type
id: repo
run: |
if [[ "${{ steps.metadata.outputs.repository_name }}" == "terraform-*-provider" ]]; then
echo "Setting repo type to Terraform Provider"
echo "type=Terraform Provider" >> $GITHUB_OUTPUT
echo "name=${${{ steps.metadata.outputs.repository_name }}#terraform-}" >> $GITHUB_OUTPUT
elif [[ "${{ steps.metadata.outputs.repository_name }}" == "terraform-aws*" ]]; then
echo "Setting repo type to Terraform Module"
echo "type=Terraform Module" >> $GITHUB_OUTPUT
echo "name=${${{ steps.metadata.outputs.repository_name }}#terraform-}" >> $GITHUB_OUTPUT
elif [[ "${{ steps.metadata.outputs.repository_name }}" == "github-action-*" ]]; then
echo "Setting repo type to GitHub Action"
echo "type=GitHub Action" >> $GITHUB_OUTPUT
echo "name=${${{ steps.metadata.outputs.repository_name }}#github-action-}" >> $GITHUB_OUTPUT
elif [[ "${{ steps.metadata.outputs.repository_name }}" == "example-*" ]]; then
echo "Setting repo type to Example"
echo "type=Example" >> $GITHUB_OUTPUT
echo "name=${${{ steps.metadata.outputs.repository_name }}#example-}" >> $GITHUB_OUTPUT
elif [[ "${{ steps.metadata.outputs.repository_name }}" == "infra-*" ]]; then
echo "Setting repo type to Infrastructure"
echo "type=Infrastructure" >> $GITHUB_OUTPUT
echo "name=${${{ steps.metadata.outputs.repository_name }}#infra-}" >> $GITHUB_OUTPUT
else
echo "Repo type is undetermined"
echo "type=Project" >> $GITHUB_OUTPUT
echo "name=${{ steps.metadata.outputs.repository_name }}" >> $GITHUB_OUTPUT
fi

- name: Generate banner image
id: screenshot
uses: cloudposse-github-actions/screenshot@main
with:
url: "file://${{github.workspace}}/banner/index.html"
output: "banner/image.png"
customizations: |
"#name": "${{ steps.repo.outputs.repository_name }}"
"#type": "${{ steps.repo.outputs.repository_name }}"
"#desc": "${{ steps.metadata.outputs.repository_description }}"
viewportWidth: 1280
viewportHeight: 320
omitBackground: true

- uses: stefanzweifel/git-auto-commit-action@v4
name: Commit artifact
id: auto-commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit_message: "chore: update repo banner image"
commit_user_name: screenshot-action 📷
commit_user_email: [email protected]
commit_author: screenshot-action 📷 <[email protected]>
file_pattern: 'banner/*.png'

- name: Add Image to Step Summary
if: steps.auto-commit.outputs.changes_detected == 'true'
run: |
echo "## Generated Screenshot" >> $GITHUB_STEP_SUMMARY
echo "![Generated Screenshot](https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.commit_hash }}/${{ steps.screenshot.outputs.file }}?raw=true)" >> $GITHUB_STEP_SUMMARY

- name: No changes
if: steps.auto-commit.outputs.changes_detected == 'false'
run: |
echo "No changes to screenshot" >> $GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions banner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This represents the HTML to generate the banner used by repositories across this organization.
1 change: 1 addition & 0 deletions banner/advanced-consulting-partner.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions banner/banner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This represents the HTML to generate the banner used by repositories across this organization.

## Current Banner
![Banner](image.png)
1 change: 1 addition & 0 deletions banner/banner/github-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added banner/banner/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
167 changes: 167 additions & 0 deletions banner/banner/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">

<title>Cloud Posse</title>
<style>
body {
overflow: hidden;
font: 16px/1.4 'proxima-nova';
font-family: 'proxima-nova', sans-serif;
margin: 0;
color: hsla(0, 0%, 100%, 0.85);
min-width: 100vw;
min-height: 100vh;
color: #fff;
background: transparent !important;
}

.highlight {
color: #ffffff40;
}

.break {
flex-basis: 100%;
height: 0;
}

.filler{
flex-grow:1;
text-align:center;
}

.container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
border-radius: 6px;
background-color: #170d24;
background-image:
radial-gradient(ellipse at 10% 90%, #3c2d83 0%, transparent 55%),
radial-gradient(ellipse at 90% 90%, #c33c65 0%, transparent 55%),
radial-gradient(ellipse at 90% 10%, #4a74dc 0%, transparent 55%),
radial-gradient(ellipse at 10% 10%, #35244f 0%, transparent 55%);
}

.banner {
max-width: 95vw;
max-height: 95vh;
height: auto;
width: 100%;
overflow: hidden;
font-size: 2.5em;
display: flex;
flex-wrap: wrap;
}

.logo {
display: flex;
width: 20vw;
flex-wrap: wrap;
}
.logo h2 {
display: flex;
flex-basis: 100%;
}

img {
width: auto;
max-width: 100%;
}

.github-partner {
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #fff;
border-radius: 12px;
padding: 0.5em;
font-size: 0.87em;
margin-top: 0.2em;
max-width: 27vw;
width: 100%;
}

.github-partner img {
max-width: 27%;
margin-right: 0.2em;
}


.subheader {
display: flex;
flex-basis: 100%;
}

.project h2 {
letter-spacing: 0.12em;
text-transform: uppercase;
font-weight: normal;
font-size: 0.7em;
}

.project h1 {
color: #d9d9d9;
font-size: 2.0em;
display: flex;
flex-basis: 100%;
margin: 0;
line-height: 1em;
}

.project .description {
line-height: 2.0em;
display: flex;
}

.project {
display: flex;
flex-wrap: wrap;
}

.branding {
display: flex;
flex-wrap: wrap;
align-items: center;
font-size: 0.7em;
overflow: hidden;
}

.branding h2 {
margin: 0;
}

.branding div {
margin-right: 0.5em;
}

</style>
</head>
<body>
<div class="container">
<div class="banner">
<div class="project">
<h2 id="type">GitHub Action</h1>
<div class="filler"></div>
<div class="github-partner"><img src="github-logo.svg"/> Verified Partner</div>
<h1 id="name">repo-name</h1>
<div id="desc" class="description">
The short and sweet description of the repo.
</div>
<div class="filler"></div>
<div class="branding">
<div class="by">by</div>
<div class="logo">
<img src="https://cloudposse.com/wp-content/uploads/2019/01/cloudposse-white.svg"/
<div class="subheader">
<h2><span class="highlight">DevOps Accelerator</span></h1>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Binary file added banner/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 492b407

Please sign in to comment.