Skip to content

Add banners and workflows #7

Add banners and workflows

Add banners and workflows #7

Workflow file for this run

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: |
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 undetermined"
fi
if [[ "${desc}" == "null" ]]; then
echo "desc=" >> $GITHUB_OUTPUT
else
# Only keep the first sentence
echo "desc=${desc/.*}" >> $GITHUB_OUTPUT
fi
source $(GITHUB_OUTPUT)
echo "name=${name}"
echo "type="${type}"
echo "desc="${desc}"
- 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.name }}"
"#type": "${{ steps.repo.outputs.type }}"
"#desc": "${{ steps.repo.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