Skip to content

updated performance.md #22

updated performance.md

updated performance.md #22

Workflow file for this run

# vim:ts=2:sts=2:sw=2:et
#
# Author: Hari Sekhon
# Date: 2024-03-22 00:24:54 +0000 (Fri, 22 Mar 2024)
#
# https///github.com/HariSekhon/Knowledge-Base
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#
---
name: Gist Sync
on:
push:
branches:
- master
- main
paths:
- '**/*.md'
- .github/workflows/gist-sync.yaml
pull_request:
branches:
- master
- main
paths:
- '**/*.md'
- .github/workflows/gist-sync.yaml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: false
defaults:
run:
shell: bash -euxo pipefail {0}
env:
GH_TOKEN: ${{ secrets.GIST_TOKEN }}
jobs:
sync-gists:
if: github.repository_owner == 'HariSekhon'
name: Sync Gists
timeout-minutes: 20
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
#- name: GitHub CLI Auth Login
# run: gh auth login --with-token <<< "$GH_TOKEN"
#
# The value of the GH_TOKEN environment variable is being used for authentication.
# To have GitHub CLI store credentials instead, first clear the value from the environment.
#
- name: Sync READMEs to Gists
run: |
gist_list="$(gh gist list -L 2000 --public)"
for readme in *.md; do
if awk '{print $2}' <<< "$gist_list" | grep -Fxq "$readme"; then
id="$(awk "/^[[:alnum:]]{32}[[:space:]]+$readme / {print \$1; exit}" <<< "$gist_list" || :)"
if [ -z "$id" ]; then
echo "Failed to determine ID for gist of file '$readme'"
exit 1
fi
gist_md5="$(gh gist view "$id" --filename "$readme" --raw | md5sum)"
readme_md5="$(cat "$readme" | md5sum)"
if [ "$gist_md5" != "$readme_md5" ]; then
echo "Updating Gist for '$readme'"
gh gist edit "$id" --filename "$readme" --desc "$readme from HariSekhon/Knowledge-Base repo: https://github.com/HariSekhon/Knowlege-Base" "$readme"
else
echo "Gist for '$readme' already matches, not updating"
fi
else
echo "Creating Gist for '$readme'"
gh gist create --public --filename "$readme" --desc "$readme from HariSekhon/Knowledge-Base repo: https://github.com/HariSekhon/Knowlege-Base" "$readme"
fi
done