Add banners and workflows #22
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |