Skip to content

Commit

Permalink
Add banners and workflows (#20)
Browse files Browse the repository at this point in the history
* add banners and workflows

* chore: update org banner image

* tune org banner

* chore: update org banner image

* remove accidental commit

* fix whitepsace

* chore: update repo banner image

* fix bash

* fix desc

* chore: update repo banner image

* output debug

* output debug

* output debug

* debug

* add test

* add test

* add test

* fix outputs

* fix typo

* fix whitespace

* chore: update repo banner image

* fix formatting

* chore: update repo banner image

* grow

* chore: update repo banner image

* fix css

* chore: update repo banner image

* tweak css

* chore: update repo banner image

* change default

* Update README to show banner

* chore: update repo banner image

* tweak css

* chore: update repo banner image

* Update README

---------

Co-authored-by: screenshot-action 📷 <[email protected]>
  • Loading branch information
osterman and actions-user authored Jan 16, 2024
1 parent b92e5f1 commit 1505016
Show file tree
Hide file tree
Showing 16 changed files with 702 additions and 123 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
97 changes: 97 additions & 0 deletions .github/workflows/repo-banner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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

- name: Fetch repo metadata
id: metadata
uses: ahmadnassri/action-metadata@v2

- name: Format Repo Metadata
id: meta
run: |
name="${{ steps.metadata.outputs.repository_name }}"
type="Project"
desc="${{ steps.metadata.outputs.repository_description }}"
if [[ "${name}" == "terraform-*-provider" ]]; then
echo "type=Terraform Provider" >> $GITHUB_OUTPUT
echo "name=${name#terraform-}" >> $GITHUB_OUTPUT
elif [[ "${name}" == "terraform-aws*" ]]; then
echo "type=Terraform Module" >> $GITHUB_OUTPUT
echo "name=${name#terraform-}" >> $GITHUB_OUTPUT
elif [[ "${name}" == "github-action-*" ]]; then
echo "type=GitHub Action" >> $GITHUB_OUTPUT
echo "name=${name#github-action-}" >> $GITHUB_OUTPUT
elif [[ "${name}" == "example-*" ]]; then
echo "type=Example" >> $GITHUB_OUTPUT
echo "name=${name#example-}" >> $GITHUB_OUTPUT
elif [[ "${name}" == "infra-*" ]]; then
echo "type=Infrastructure" >> $GITHUB_OUTPUT
echo "name=${name#infra-}" >> $GITHUB_OUTPUT
else
echo "Repo type is indeterminable"
echo "name=${name}" >> $GITHUB_OUTPUT
echo "type=${type}" >> $GITHUB_OUTPUT
fi
if [[ "${desc}" == "null" ]]; then
echo "desc=" >> $GITHUB_OUTPUT
else
# Only keep the first sentence
echo "desc=${desc/.*}" >> $GITHUB_OUTPUT
fi
cat ${GITHUB_OUTPUT}
- 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.meta.outputs.name }}"
"#type": "${{ steps.meta.outputs.type }}"
"#desc": "${{ steps.meta.outputs.desc }}"
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
Loading

0 comments on commit 1505016

Please sign in to comment.